vb编程在picturebox画圆
我要画那种弹性的图形,鼠标拖动时形状会变的圆PrivateSubPicture1_MouseDown(ButtonAsInteger,ShiftAsInteger,XAs...
我要画那种弹性的图形,鼠标拖动时形状会变的圆
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
formerX = X
formerY = Y
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)'鼠标移动
If Button = 1 Then
Picture1.Cls
For i = 1 To drawcount
With drawone(i)
rl = Sqr(((.x1 - .x2) ^ 2 + (.y1 - .y2) ^ 2))
Picture1.Circle (.x1, .y1), rl, .dcolor
End with
rl = Sqr((formerX - X) ^ 2 + (formerY - Y) ^ 2)
Picture1.Circle (formerX, formerY), rl
End if
End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)'释放鼠标后
rl = Sqr((formerX - X) ^ 2 + (formerY - Y) ^ 2)
Picture1.Circle (formerX, formerY), rl
drawcount = drawcount + 1
If drawcount > 0 Then '动态数组存储图形信息
ReDim Preserve drawone(1 To drawcount)
With drawone(drawcount)
.x1 = formerX
.y1 = formerY
.x2 = X
.y2 = Y
.drawtype = drawt
.dcolor = Picture1.ForeColor
End With
End If
这个程序画出来的圆在中心水平线上半径是鼠标拖出来的半径,但在鼠标和中心在竖直线上的时候偏移量很大,怎么解决?
第二位画出来的鼠标位置确实是确定了半径,但是只能画圆弧吗? 展开
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
formerX = X
formerY = Y
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)'鼠标移动
If Button = 1 Then
Picture1.Cls
For i = 1 To drawcount
With drawone(i)
rl = Sqr(((.x1 - .x2) ^ 2 + (.y1 - .y2) ^ 2))
Picture1.Circle (.x1, .y1), rl, .dcolor
End with
rl = Sqr((formerX - X) ^ 2 + (formerY - Y) ^ 2)
Picture1.Circle (formerX, formerY), rl
End if
End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)'释放鼠标后
rl = Sqr((formerX - X) ^ 2 + (formerY - Y) ^ 2)
Picture1.Circle (formerX, formerY), rl
drawcount = drawcount + 1
If drawcount > 0 Then '动态数组存储图形信息
ReDim Preserve drawone(1 To drawcount)
With drawone(drawcount)
.x1 = formerX
.y1 = formerY
.x2 = X
.y2 = Y
.drawtype = drawt
.dcolor = Picture1.ForeColor
End With
End If
这个程序画出来的圆在中心水平线上半径是鼠标拖出来的半径,但在鼠标和中心在竖直线上的时候偏移量很大,怎么解决?
第二位画出来的鼠标位置确实是确定了半径,但是只能画圆弧吗? 展开
2个回答
展开全部
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 1 Then x1 = x: y1 = y
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 1 Then
Picture1.AutoRedraw = False
Picture1.Refresh
Picture1.PSet (x1, y1)
Picture1.Circle (x1, y1), Sqr((x - x1) ^ 2 + (y - y1) ^ 2)
End If
End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 1 Then
Picture1.AutoRedraw = True
Picture1.Circle (x1, y1), Sqr((x - x1) ^ 2 + (y - y1) ^ 2), End If
End Sub
If Button = 1 Then x1 = x: y1 = y
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 1 Then
Picture1.AutoRedraw = False
Picture1.Refresh
Picture1.PSet (x1, y1)
Picture1.Circle (x1, y1), Sqr((x - x1) ^ 2 + (y - y1) ^ 2)
End If
End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 1 Then
Picture1.AutoRedraw = True
Picture1.Circle (x1, y1), Sqr((x - x1) ^ 2 + (y - y1) ^ 2), End If
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
是不是圆心偏左?
还是没看懂你的问题在哪儿,呵呵
还是没看懂你的问题在哪儿,呵呵
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询