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!
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Scott LyslePosted Mar 15, 2007, 2:12 AM
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)