用VB画的凸轮,程序如下,怎么让他以(Form1.Width / 2,Form1.Height / 2)为中心逆时针转动?请教大神
PrivateSubCommand1_Click()pi=3.14159265DimiAsIntegerDimx(360)AsSingleDimy(360)AsSingl...
Private Sub Command1_Click()
pi = 3.14159265
Dim i As Integer
Dim x(360) As Single
Dim y(360) As Single
Show
Line (Form1.Width / 2 + 1000, Form1.Height / 2)-(Form1.Width / 2 + 1000, Form1.Height / 2)
For i = 1 To 206
x(i) = Form1.Width / 2 + (1000 + 7.8 * i) * Cos(i * pi / 180)
y(i) = Form1.Height / 2 + (1000 + 7.8 * i) * Sin(i * pi / 180)
Line -(x(i), y(i))
Next i
For i = 207 To 309
x(i) = Form1.Width / 2 + (2600 - 15.6 * (i - 206)) * Cos(i * pi / 180)
y(i) = Form1.Height / 2 + (2600 - 15.6 * (i - 206)) * Sin(i * pi / 180)
Line -(x(i), y(i))
Next i
For i = 310 To 360
x(i) = Form1.Width / 2 + 1000 * Cos(i * pi / 180)
y(i) = Form1.Height / 2 + 1000 * Sin(i * pi / 180)
Line -(x(i), y(i))
Next i
End Sub 展开
pi = 3.14159265
Dim i As Integer
Dim x(360) As Single
Dim y(360) As Single
Show
Line (Form1.Width / 2 + 1000, Form1.Height / 2)-(Form1.Width / 2 + 1000, Form1.Height / 2)
For i = 1 To 206
x(i) = Form1.Width / 2 + (1000 + 7.8 * i) * Cos(i * pi / 180)
y(i) = Form1.Height / 2 + (1000 + 7.8 * i) * Sin(i * pi / 180)
Line -(x(i), y(i))
Next i
For i = 207 To 309
x(i) = Form1.Width / 2 + (2600 - 15.6 * (i - 206)) * Cos(i * pi / 180)
y(i) = Form1.Height / 2 + (2600 - 15.6 * (i - 206)) * Sin(i * pi / 180)
Line -(x(i), y(i))
Next i
For i = 310 To 360
x(i) = Form1.Width / 2 + 1000 * Cos(i * pi / 180)
y(i) = Form1.Height / 2 + 1000 * Sin(i * pi / 180)
Line -(x(i), y(i))
Next i
End Sub 展开
2个回答
展开全部
窗体放一个command1,一个tiemr1
Const pi = 3.14159265
Dim agl As Double
Private Sub draw()
Dim i As Integer
Show
Line (Form1.Width / 2 + 1000 * Cos(agl), Form1.Height / 2 + 1000 * Sin(agl))-(Form1.Width / 2 + 1000 * Cos(agl), Form1.Height / 2 + 1000 * Sin(agl))
For i = 1 To 206
x = Form1.Width / 2 + (1000 + 7.8 * i) * Cos(i * pi / 180 + agl)
y = Form1.Height / 2 + (1000 + 7.8 * i) * Sin(i * pi / 180 + agl)
Line -(x, y)
Next i
For i = 207 To 309
x = Form1.Width / 2 + (2600 - 15.6 * (i - 206)) * Cos(i * pi / 180 + agl)
y = Form1.Height / 2 + (2600 - 15.6 * (i - 206)) * Sin(i * pi / 180 + agl)
Line -(x, y)
Next i
For i = 310 To 360
x = Form1.Width / 2 + 1000 * Cos(i * pi / 180 + agl)
y = Form1.Height / 2 + 1000 * Sin(i * pi / 180 + agl)
Line -(x, y)
Next i
End Sub
Private Sub Command1_Click()
If Timer1.Enabled = False Then
Timer1.Enabled = True
Else
Timer1.Enabled = False
End If
End Sub
Private Sub Form_Load()
Timer1.Interval = 30
End Sub
Private Sub Timer1_Timer()
agl = agl + pi / 50
If agl >= 2 * pi Then agl = 0
Form1.Cls
draw
End Sub
Const pi = 3.14159265
Dim agl As Double
Private Sub draw()
Dim i As Integer
Show
Line (Form1.Width / 2 + 1000 * Cos(agl), Form1.Height / 2 + 1000 * Sin(agl))-(Form1.Width / 2 + 1000 * Cos(agl), Form1.Height / 2 + 1000 * Sin(agl))
For i = 1 To 206
x = Form1.Width / 2 + (1000 + 7.8 * i) * Cos(i * pi / 180 + agl)
y = Form1.Height / 2 + (1000 + 7.8 * i) * Sin(i * pi / 180 + agl)
Line -(x, y)
Next i
For i = 207 To 309
x = Form1.Width / 2 + (2600 - 15.6 * (i - 206)) * Cos(i * pi / 180 + agl)
y = Form1.Height / 2 + (2600 - 15.6 * (i - 206)) * Sin(i * pi / 180 + agl)
Line -(x, y)
Next i
For i = 310 To 360
x = Form1.Width / 2 + 1000 * Cos(i * pi / 180 + agl)
y = Form1.Height / 2 + 1000 * Sin(i * pi / 180 + agl)
Line -(x, y)
Next i
End Sub
Private Sub Command1_Click()
If Timer1.Enabled = False Then
Timer1.Enabled = True
Else
Timer1.Enabled = False
End If
End Sub
Private Sub Form_Load()
Timer1.Interval = 30
End Sub
Private Sub Timer1_Timer()
agl = agl + pi / 50
If agl >= 2 * pi Then agl = 0
Form1.Cls
draw
End Sub
追问
您好,怎么让他逆时针转呢?
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
?请教大神
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询