我想做曲线,用点画一个cos曲线和y=x^2的曲线,代码如下:
Private Sub Command1_Click()
kuan = Picture1.Width
gao = Picture1.Height
Picture1.Line (kuan / 2, 0)-(kuan / 2, gao), vbRed
Picture1.Line (0, gao / 2)-(kuan, gao / 2), vbRed
For i = gao / 2 To 0 Step -500
Picture1.Line (kuan / 2, i)-(kuan / 2 + 70, i), vbRed
Next i
For i = gao / 2 To gao Step 500
Picture1.Line (kuan / 2, i)-(kuan / 2 + 70, i), vbRed
Next i
For i = kuan / 2 To 0 Step -500
Picture1.Line (i, gao / 2)-(i, gao / 2 - 70), vbRed
Next i
For i = kuan / 2 To kuan Step 500
Picture1.Line (i, gao / 2)-(i, gao / 2 - 70), vbRed
Next i
For i = -kuan / 2 To kuan / 2
Picture1.PSet (i + kuan / 2, gao / 2 - Cos(i * 3.14159 / 180) * 500), vbGreen
Picture1.PSet (i + kuan / 2, gao / 2 - i * i / 500), vbBlue
Next i
End Sub
Private Sub Command2_Click()
Picture1.Cls
End Sub
Private Sub Command3_Click()
End
End Sub
———————————————————————————————————————————————————
Picture1.PSet (i + kuan / 2, gao / 2 - Cos(i * 3.14159 / 180) * 500), vbGreen
Picture1.PSet (i + kuan / 2, gao / 2 - i * i / 500), vbBlue
这两行我搞不懂了啊哈,为什么Cos(i * 3.14159 / 180) * 500和i * i / 500才能正确显示,如果Cos(i * 3.14159 / 180) /500和i * i *500均不能正确显示。
希望大虾指导一下,小弟先谢谢了哈!