vb中可通过什么方法画椭圆

vb中可通过什么方法画椭圆,第1张

obj.Circle (x, y), r, c, s, e, k

obj 是要画椭圆的对象,可以是窗体或图片框,如Form1或Picture1

(x, y) 圆心坐标

r 半径

c 边线颜色

s和e 是起始角和终止角,画弧线或扇形的时候才需要用到,这里可以留空

k 是椭圆的高宽比例

下面的代码将在当前窗口的中心画一个红色的、宽是高2倍的椭圆:

Me.Circle (Me.ScaleWidth \ 2, Me.ScaleHeight \ 2), Me.ScaleHeight \ 3, vbRed, , , 0.5

Dim LastX As Single

Dim LastY As Single

Dim NowClick As Boolean

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

LastX = X

LastY = Y

NowClick = True

End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

If NowClick Then DrawOval X, Y, False

End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

DrawOval X, Y, True

NowClick = False

End Sub

Sub DrawOval(Sx As Single, Ey As Single, Optional DrawNow As Boolean = False)

If DrawNow Then '画出

If Sx <= LastX Or Ey <= LastY Then Exit Sub

If (Ey - LastY) <= (Sx - LastY) Then

Me.Circle ((Sx - LastX) / 2 + LastX, (Ey - LastY) / 2 + LastY), (Sx - LastX) / 2, , , , (Ey - LastY) / (Sx - LastX)

Else

Me.Circle ((Sx - LastX) / 2 + LastX, (Ey - LastY) / 2 + LastY), (Ey - LastY) / 2, , , , (Ey - LastY) / (Sx - LastX)

End If

Else'模拟

If Sx <= LastX Or Ey <= LastY Then Exit Sub

Me.Cls

If (Ey - LastY) <= (Sx - LastY) Then

Me.Circle ((Sx - LastX) / 2 + LastX, (Ey - LastY) / 2 + LastY), (Sx - LastX) / 2, , , , (Ey - LastY) / (Sx - LastX)

Else

Me.Circle ((Sx - LastX) / 2 + LastX, (Ey - LastY) / 2 + LastY), (Ey - LastY) / 2, , , , (Ey - LastY) / (Sx - LastX)

End If

End If

End Sub


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/12141451.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-21
下一篇2023-05-21

发表评论

登录后才能评论

评论列表(0条)

    保存