Public Class Form1
Dim g As Graphics
Dim x1, y1, x2, y2 As Single
Dim r
Dim angle
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
g = Me.CreateGraphics
Me.BackColor = Color.White
Timer1.Enabled = True
Timer1.Interval = 100
x1 = 300
y1 = 300
r = 200
angle = 0
End Sub
Sub draw()
g.DrawLine(Pens.Black, x1, y1, x2, y2)
End Sub
Sub drawWhite()
g.DrawLine(Pens.White, x1, y1, x2, y2)
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
drawWhite()
angle = angle + 30
x2 = 300 + r * Math.Cos(angle * 3.14 / 180) '弳度 = 角度 * 3.14/180
y2 = 300 + r * Math.Sin(angle * 3.14 / 180)
draw()
End Sub
End Class
沒有留言:
張貼留言