lph
asked on
drawing random dots on mouseclick
i would like the user to be able to draw random size of dots when the user click on a picture box (something like the spray function in Paint)... the random size of dots should be different sizes of circles...how to do that?
ASKER
what i wanted is on mouse_down, it will draw a few circles or dots of different sizes at one time and the dots are near each other.
i want the dots to be solid type (the whole circle is black, for example) and not with the circle in the middle...
i want the dots to be solid type (the whole circle is black, for example) and not with the circle in the middle...
Set the .FillColor to the color you want it to be filled with, and then In _MouseDown put:
Picture1.Circle X, Y, CInt(Rnd*10), Picture1.FillColor
Picture1.Circle X, Y, CInt(Rnd*10), Picture1.FillColor
ASKER
i need a few dots to be drawn at one mouse_click (like the one in the spray function in Paint).. your command only draw one dot at one time...
Picture1.Circle X-5+cint(rnd*10), Y-5+cint(rnd*10), CInt(Rnd*10), Picture1.FillColor
ASKER
This does not do something like the spray function in Paint...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i want the dots to be drawn on mouse click and not on mouse down...
and the dots that are to be drawn should appear around the mouse cursor and not anywhere in the picture box...
and the dots that are to be drawn should appear around the mouse cursor and not anywhere in the picture box...
You could customize the code as you want it...
My code draw filled circles with random radius (from 0 to 10)
at a random position into a rectangle centered on the mouse (the size of the rectangle is 200).
My picture as width and height = 1500
In Paintbrush, the spray draw continuously (every 10ms) between the mousedown and the mouseup. That is not what you want ?
My code draw filled circles with random radius (from 0 to 10)
at a random position into a rectangle centered on the mouse (the size of the rectangle is 200).
My picture as width and height = 1500
In Paintbrush, the spray draw continuously (every 10ms) between the mousedown and the mouseup. That is not what you want ?
The MouseClick event is fired after the MouseDown and MouseUp events. So if you start to draw on MouseClick, when do you STOP to draw circles ???
ASKER
sorry, what i mean is i want the dots to be drawn on mouse down and not on mouse move....
Can't you change the code as follow by yourself...?
Option Explicit
Private x0 As Integer, y0 As Integer
Private Const pi = 3.141592
Private Sub Form_Load()
Randomize Timer
End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
x0 = X
y0 = Y
Picture1.FillStyle = vbFSSolid
Timer1.Enabled = True
Timer1.Interval = 10
End If
End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
'Draw random circle into a circle
Dim a As Double
a = Rnd * 2 * pi
Picture1.Circle (x0 + CInt(200 * Rnd * Cos(a)), y0 + CInt(200 * Rnd * Sin(a))), CInt(Rnd * 50)
End Sub
Option Explicit
Private x0 As Integer, y0 As Integer
Private Const pi = 3.141592
Private Sub Form_Load()
Randomize Timer
End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
x0 = X
y0 = Y
Picture1.FillStyle = vbFSSolid
Timer1.Enabled = True
Timer1.Interval = 10
End If
End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
'Draw random circle into a circle
Dim a As Double
a = Rnd * 2 * pi
Picture1.Circle (x0 + CInt(200 * Rnd * Cos(a)), y0 + CInt(200 * Rnd * Sin(a))), CInt(Rnd * 50)
End Sub
Randomize Timer
In _MouseDown put:
Picture1.Circle X, Y, CInt(Rnd*10)