【发布时间】:2020-08-08 15:56:48
【问题描述】:
我知道如何使用 top-sx 角作为枢轴来旋转文本或矩形。例如:
Private Sub Panel1_Click(sender As Object, e As EventArgs) Handles Panel1.Click
Dim g As Graphics = Panel1.CreateGraphics()
Dim font As Font = New Font("Arial", 42, FontStyle.Regular, GraphicsUnit.Pixel)
Dim i As Single
For i = 0 To 255 Step 30
Dim myBrush As SolidBrush = New SolidBrush(Color.FromArgb(255, i, 255 - i, i)) 'Green to violet
'Draw a string and a Rectangle of the same size
Dim stringSize As SizeF = g.MeasureString("Hello", font)
g.TranslateTransform(200, 200)
g.RotateTransform(-i)
g.DrawString("Hello", font, myBrush, 0, 0)
g.DrawRectangle(New Pen(Color.FromArgb(50, 255, 0, 0), 1), 0, 0, stringSize.Width, stringSize.Height)
g.ResetTransform()
myBrush.Dispose()
Next
'Draw the center of the rotation
g.DrawRectangle(Pens.Black, 200 - 5, 200 - 5, 10, 10)
g.Dispose()
End Sub
使用此代码,我有以下输出:
如何使用底部 sx 角作为枢轴旋转我的图形元素?
【问题讨论】:
标签: vb.net graphics gdi+ rotatetransform