请问在vb中,用circle和line画出来的圆的轮廓为什么会不重合?

来源:百度知道 编辑:UC知道 时间:2024/06/09 19:40:17
如:Private Sub Form_Load()
scale (-50,50)-(50,-50)
end sub
Private Sub Timer1_Timer()
Static i
x=cos(i)*25:y=sin(i)*25
line (0,0)-(x,y)
i=i+3.141592654/180
circle (0,0),25
end sub
运行结果两圆的轮廓不重合。求助各位大侠帮助一下!!!

这可能是VB的一个BUG,当画线的单位是像素时,虽然两条线是一样的长度,但若一横一竖,则画出来总是横长竖短。要解决这个问题,你最好不要用像素为单位,改为用twip为单位。修改如下:
Dim a As Integer, b As Integer, r As Integer
Private Sub Form_Load()
a = 4000 '圆心横坐标
b = 2500 '圆心纵坐标
r = 1500 '半径
End Sub
Private Sub Timer1_Timer()
Static i
x = Cos(i) * r: y = Sin(i) * r
Line (a, b)-(x + a, y + b)
i = i + 3.141592654 / 180
Circle (a, b), r
End Sub

重定位下 坐标