我如何在 c#
应用程序中翻转字符串,例如:“AMBULANCE”文本被视为镜像。我不知道从哪里开始使用 .im 使用 c#
表单应用程序
我试过反转字符串,但是否有可能翻转字符串(如镜像)?
喜欢:ƎƆИA⅃UᙠMA
这不是在 SO post 中反转
最佳答案
除了 Sergey 概述的方法外,您还可以使用 Graphics.ScaleTransform()
反射(reflect)关于 Y 轴的一切。
例如,创建一个默认的 Windows 窗体应用程序并将以下 OnPaint()
放入其中,然后运行它:
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
string text = "This will come out backwards";
e.Graphics.ScaleTransform(-1, 1);
float w = e.Graphics.MeasureString(text, this.Font).Width;
e.Graphics.DrawString(text, this.Font, Brushes.Black, -w, 0);
}
输出:
您也可以使用 Graphics.RotateTransform()
来旋转文本,并使用 Graphics.ScaleTransform(1, -1)
将其反转为以及镜像它:
关于c# - 如何翻转字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30568360/