Simulating Freehand Drawing With Ellipses

Anticipation

Member
Joined
Jul 15, 2008
Messages
10
Programming Experience
Beginner
Hi, I'm trying to make a Freehand drawing tool in a program that uses Ellipses closely packed together. On the MouseDown Event, I've got
VB.NET:
Dim g As Graphics = pictureBox1.CreateGraphics
Dim p As New Pen(PenColor, PenWidth)
		
XPrev = e.X
YPrev = e.Y


If e.Button = MouseButtons.Left And DrawType = "Freehand" Then
			g.DrawEllipse(p, e.X - CInt(0.5 * PenWidth), e.Y - CInt(0.5 * PenWidth), PenWidth, PenWidth)
		End If
which draws one ellipse, and on the MouseMove event, i've got
VB.NET:
Dim g As Graphics = pictureBox1.CreateGraphics
Dim p As New Pen(PenColor, PenWidth)


If e.Button = MouseButtons.Left And DrawType = "FreeHand" Then
			If PenWidth <= 1 Then g.DrawLine(p, XPrev, YPrev, e.X, e.Y)
			If PenWidth > 1 Then g.DrawEllipse(p, e.X - CInt(0.5 * PenWidth), e.Y - CInt(0.5 * PenWidth), PenWidth, PenWidth)
			XPrev = e.X
			YPrev = e.Y
End If
The problem is, that when i click on my PictureBox, and move my cursor, one small ellipse appears, and nothing else.

Any suggestions ?

Thanks
 
Back
Top