Private Sub Form1_Paint(ByVal sender As Object, ByVal e As _
System.Windows.Forms.PaintEventArgs) Handles _
MyBase.Paint
' Draw a transformed rectangle and some ellipses.
e.Graphics.ScaleTransform(1.5, 1.5, MatrixOrder.Append)
e.Graphics.TranslateTransform(80, 20)
e.Graphics.RotateTransform(20, MatrixOrder.Append)
e.Graphics.DrawRectangle(Pens.Blue, 0, 0, 100, 100)
e.Graphics.DrawEllipse(Pens.Red, -3, -3, 6, 6)
e.Graphics.DrawEllipse(Pens.Yellow, 97, 97, 6, 6)
' Draw untransformed text starting at the
' transformed location (0, 0).
' Transform the point (0, 0) to see where it goes.
Dim pts() As Point = {New Point(0, 0)}
e.Graphics.Transform.TransformPoints(pts)
' Make a transformation that draws rotated text
' translated to this point.
' Reset the transformation.
e.Graphics.ResetTransform()
' Rotate.
e.Graphics.RotateTransform(20, MatrixOrder.Append)
' Translate to the target point's transformed location.
e.Graphics.TranslateTransform(pts(0).X, pts(0).Y, _
MatrixOrder.Append)
' Draw the text at (0, 0).
Dim the_font As New Font("Times New Roman", 20, _
FontStyle.Regular, GraphicsUnit.Pixel)
e.Graphics.DrawString("WYSIWYG", the_font, _
Brushes.Brown, 0, 0)
the_font.Dispose()
End Sub
|