7,765
社区成员
发帖
与我相关
我的任务
分享
Option Explicit
Const pi = 3.1415926
Private Type point2d
x As Single
y As Single
End Type
Dim pt(2) As point2d
Private Sub Command1_Click()
pt(0).x = -1500
pt(0).y = 1000
pt(1).x = 1500
pt(1).y = 500
pt(2).x = 1000
pt(2).y = -1500
'首先清除picture1内的图形
Picture1.Cls
Picture1.Scale (-2000, 2000)-(2000, -2000)
'设置绘线宽度
Picture1.DrawWidth = 1
DrawTriangle pt
Timer1.Interval=100
Timer1.Enabled = True
Picture1.ForeColor = vbBlue
End Sub
Private Sub ChangCoord(ByRef pt() As point2d, Angle As Single)
Dim i As Long, x As Single, y As Single
For i = 0 To UBound(pt)
x = pt(i).x * Cos(Angle) - pt(i).y * Sin(Angle)
y = pt(i).y * Cos(Angle) + pt(i).x * Sin(Angle)
pt(i).x = x
pt(i).y = y
Next i
End Sub
Private Sub DrawTriangle(ByRef pt() As point2d)
If UBound(pt) <> 2 Then Exit Sub
Picture1.Line (pt(0).x, pt(0).y)-(pt(1).x, pt(1).y), vbBlue
Picture1.Line -(pt(2).x, pt(2).y), vbBlue
Picture1.Line -(pt(0).x, pt(0).y), vbBlue
End Sub
Private Sub Timer1_Timer()
ChangCoord pt, pi / 50
Picture1.Cls
DrawTriangle pt
End Sub
Const n = 3.14159 / 4
Private Sub Form_Load()
Picture1.Width = Picture1.Height
Picture1.AutoRedraw = True
Picture1.Scale (-100, -100)-(100, 100)
Picture1.Line (-70, 70)-(80, 70), vbRed
Picture1.Line -(-20, -50), vbRed
Picture1.Line -(-70, 70), vbRed
End Sub
'X =x*cos(n)+y*sin(n)
'Y =y*cos(n)-x*sin(n)
Private Sub Picture1_Click()
Picture1.Cls
X1 = -70 * Cos(n) + 70 * Sin(n)
Y1 = 70 * Cos(n) + 70 * Sin(n)
X2 = 80 * Cos(n) + 70 * Sin(n)
Y2 = 70 * Cos(n) - 80 * Sin(n)
X3 = -20 * Cos(n) - 50 * Sin(n)
Y3 = -50 * Cos(n) + 20 * Sin(n)
Picture1.Line (X1, Y1)-(X2, Y2), vbRed
Picture1.Line -(X3, Y3), vbRed
Picture1.Line -(X1, Y1), vbRed
End Sub
'在屏幕上输出阿基米德曲线
Private Const PI = 3.141593
Private Sub Form_Load()
Me.Scale (-600, -600)-(600, 600)
Me.Show
Me.DrawWidth = 3
Me.AutoRedraw = True
Dim t As Single
Dim r As Single
Dim x As Single
Dim y As Single
For t = 0 To 20 * PI Step 0.01
r = 10 * (1 + t)
x = r * Cos(t)
y = r * Sin(t)
PSet (x, y), vbRed
Next
End Sub