How do I change the direction of a text by degrees?
I draw a text with DrawString and I want to change its direction by degrees.
How do I do that?
Thanks!
How do I change the direction of a text by degrees?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Scott LysleRank #49 · 31K reputationPosted Mar 14, 2007, 10:12 PM EDT
Use RotateTransform; see last two lines below - this will draw the text at 45 degrees.
G As GraphicsDim
G = Me.CreateGraphics
Dim largefont As New Font("Arial", 28, FontStyle.Bold, GraphicsUnit.Point)
Dim gradientStart As New Point(0, 0)
Dim txt As String = "Elephant"
Dim txtSize As New SizeF()
txtSize = G.MeasureString(txt, largefont)
Dim gradientEnd As New Point(txtSize.Width, txtSize.Height)
Dim grBrush As New LinearGradientBrush(gradientStart, gradientEnd, Color.Red, Color.Blue)
G.RotateTransform(Convert.ToSingle(45))
G.DrawString(txt, largefont, grBrush, 250, -150)