旋转使用 GraphicsPath 绘制的多边形

Rotate a polygon drawn with GraphicsPath

我想在右上角将多边形旋转-90度。

这是我绘制多边形的代码:

Private Sub Form1_Click(sender As Object, e As EventArgs) Handles MyBase.Click
    Dim g As Graphics = Me.CreateGraphics()
    Dim p As New Drawing2D.GraphicsPath()

    Dim startPoint As Point = PointToClient(Cursor.Position)

    Dim littleAngle As Integer = 4
    Dim anglesDifference As Integer = 2
    Dim bigAngle As Integer = littleAngle + anglesDifference
    Dim bigSegment As Integer = 50

    Dim p1, p2, p3, p4, p5 As Point

    p1 = New Point(startPoint.X + littleAngle, startPoint.Y - littleAngle)
    p2 = New Point(startPoint.X + littleAngle + bigSegment, startPoint.Y - littleAngle)
    p3 = New Point(startPoint.X + littleAngle + bigSegment + littleAngle, startPoint.Y)
    p4 = New Point(startPoint.X + littleAngle - anglesDifference + bigSegment, startPoint.Y + bigAngle)
    p5 = New Point(startPoint.X + bigAngle, startPoint.Y + bigAngle)

    p.AddLines({startPoint, p1, p2, p3, p4, p5})

    Dim pen As New Pen(Color.Red, 1)
    g.FillPath(New SolidBrush(Color.Red), p)
    g.DrawPath(pen, p)

    Dim translateMatrix As New Matrix
    translateMatrix.RotateAt(-90, New PointF(p.GetBounds.Width, 0))
    p.Transform(translateMatrix)

    g.FillPath(New SolidBrush(Color.Red), p)
    g.DrawPath(pen, p)
End Sub

这是使用上面的代码绘制的内容:

这是我想要的示例:

要得到你想要的,只需将 translateMatrix.RotateAt(-90, New PointF(p.GetBounds.Width, 0)) 替换为:

translateMatrix.RotateAt(-90, p3)