Imports System.Drawing.Drawing2D
Public Class Form1
Dim bmp1 As Bitmap
Dim g1 As Graphics
Dim mymatrix As New Matrix
Dim mypen As Pen
Dim angle1 As Single = 0
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
bmp1 = New Bitmap(400, 300)
g1 = Graphics.FromImage(bmp1)
g1.Clear(Color.White)
mypen = New Pen(Color.Red, 3)
g1.DrawLine(Pens.Black, 0, 130, 399, 130)
g1.DrawLine(Pens.Black, 200, 0, 200, 299)
rotateEllipse(mymatrix, mypen, g1, angle1, 100, 80, 200, 100) '旋轉0度
angle1 = 45
rotateEllipse(mymatrix, mypen, g1, angle1, 100, 80, 200, 100) '旋轉45度。
g1.DrawLine(Pens.LightSkyBlue, 0, 130, 399, 130)
PictureBox1.Image = bmp1
End Sub
Public Sub rotateEllipse(ByVal mtr As Matrix, ByVal ps As Pen, ByVal rg As Graphics, ByVal a As Single, ByVal x As Integer, ByVal y As Integer, ByVal w As Integer, ByVal h As Integer)
mtr.RotateAt(a, New PointF((w / 2) + x, (h / 2) + y))
rg.Transform = mtr
rg.DrawEllipse(ps, x, y, w, h)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End
End Sub
End Class
沒有留言:
張貼留言