Private Sub Form1_Paint(ByVal sender As Object, ByVal e As _
System.Windows.Forms.PaintEventArgs) Handles _
MyBase.Paint
Dim gr As Graphics = e.Graphics
Dim pts() As PointF = { _
New PointF(20.0F, 60.0F), _
New PointF(25.0F, 90.0F), _
New PointF(15.0F, 110.0F), _
New PointF(15.0F, 145.0F), _
New PointF(55.0F, 145.0F), _
New PointF(55.0F, 110.0F), _
New PointF(30.0F, 90.0F), _
New PointF(50.0F, 60.0F) _
}
Dim path As New GraphicsPath
path.AddLines(pts)
path.CloseFigure()
' Draw the path before applying a warp transformation.
gr.DrawPath(Pens.Blue, path)
' Define a warp transformation, and warp the path.
Dim src_rect As New RectangleF(10.0F, 50.0F, 50.0F, _
100.0F)
Dim dest_pts() As PointF = { _
New PointF(120.0F, 10.0F), _
New PointF(200.0F, 10.0F), _
New PointF(100.0F, 150.0F), _
New PointF(400.0F, 150.0F) _
}
path.Warp(dest_pts, src_rect)
' Draw the warped path.
gr.DrawPath(Pens.Green, path)
' Draw the source rectangle and the destination polygon.
gr.DrawRectangle(Pens.Black, Rectangle.Round(src_rect))
' gr.DrawPolygon(Pens.White, dest_pts)
gr.DrawLine(Pens.Red, dest_pts(0), dest_pts(1))
gr.DrawLine(Pens.Red, dest_pts(0), dest_pts(2))
gr.DrawLine(Pens.Red, dest_pts(1), dest_pts(3))
gr.DrawLine(Pens.Red, dest_pts(2), dest_pts(3))
End Sub
|