Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to flip a string?

Tags:

c#

winforms

How can i flip a string in c# application like for example : "AMBULANCE" text that is seen as mirror image.I dont have any idea to where to start with .im using c# forms application

I have tried for reversing the string ,but is there any possibility to flip a string (like mirror images)?

Like : ƎƆИA⅃UᙠMA

This is not reversing as in SO post

like image 334
Tharif Avatar asked Dec 14 '22 14:12

Tharif


1 Answers

As well as the approach outlined by Sergey, you can also use Graphics.ScaleTransform() to reflect everything about the Y-axis.

For example, create a default Windows Forms application and drop the following OnPaint() into it, then run it:

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);
}

Output:

The text reflected about Y

You can also mess around with Graphics.RotateTransform() to rotate the text as well, and use Graphics.ScaleTransform(1, -1) to invert it as well as mirror it:

enter image description here

like image 106
Matthew Watson Avatar answered Dec 30 '22 17:12

Matthew Watson