回复 10楼 lowxiong
我先不管怎么拖动画圆了,先画两个现成的圆,我写了这段代码,可以实现在一个区域内点一下可以画出一条直线,但怎么写可以把这个区域一这样画线的方式填充好,我试着谢了好几次都不行,前辈帮我补充一下
Dim rgbColor As String
Dim dr As Single
Dim dg As Single
Dim db As Single
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
rgbColor = Hex(Me.Point(x, y))
rgbColor = Change2RGB(rgbColor)
Call printline(x, y)
End Sub
Private Sub Form_paint()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Circle (2000, 2000), 1000, RGB(0, 0, 0)
Circle (2800, 2800), 1000, RGB(0, 0, 0)
End Sub
Private Function printline(x As Single, y As Single)
Dim lx As Single
Dim ly As Single
Dim rx As Single
Dim ry As Single
Dim loopflag As Boolean
loopflag = True
lx = x - 1
Do While loopflag
If Change2RGB(Me.Point(lx, y)) <> rgbColor Then
loopflag = False
Else
lx = lx - 1
End If
Loop
loopflag = True
rx = x + 1
Do While loopflag
If Change2RGB(Me.Point(rx, y)) <> rgbColor Then
loopflag = False
Else
rx = rx + 1
End If
Loop
Me.Line (lx, y)-(rx, y), RGB(Val(Text1.Text), Val(Text2.Text), Val(Text3.Text))
End Function
Private Function Change2RGB(c As String)
Select Case Len(c)
Case 1: Change2RGB = "00000" & c
Case 2: Change2RGB = "0000" & c
Case 3: Change2RGB = "000" & c
Case 4: Change2RGB = "00" & c
Case 5: Change2RGB = "0" & c
End Select
End Function