I'm programming a paint program.
When the user draws a line, I use this code, and it works as expected.
_Pen = New Drawing.Pen(_Color, _sngThickness)
_Pen.StartCap = Drawing2D.LineCap.Round
_Pen.EndCap = Drawing2D.LineCap.Round
Using g As Graphics = Graphics.FromImage(_bmp)
modControls.GraphicsSetSmoothingMode(g)
g.DrawLine(_Pen, _Last.LastX, _Last.LastY, X, Y)
End Using
However, when the user draws a single dot and not a line, DrawLine doesn't work. Therefore I'm using DrawEllipse.
However, the width / height of the drawn ellipse seems unpredictable and I just can't make out the correct formula. The single dot width / height looks like it's 80% of the line width.
This is what I'm using
Using g As Graphics = Graphics.FromImage(_bmp)
modControls.GraphicsSetSmoothingMode(g)
Dim nRect As New Rectangle(X - (_sngThickness / 8), Y - (_sngThickness / 8), _sngThickness / 4, _sngThickness / 4)
g.DrawEllipse(_Pen, nRect)
End Using
Does anybody seem what I'm doing wrong?
Also, my ellipse isn't filled, but I guess that's another problem.
Per the comment I made, try switching to a brush instead of a pen and use the FillEllipse method instead:
Using g As Graphics = Graphics.FromImage(_bmp)
modControls.GraphicsSetSmoothingMode(g)
Dim nRect As New Rectangle(X - (_sngThickness / 2), Y - (_sngThickness / 2),
_sngThickness, _sngThickness)
g.FillEllipse(_Brush, nRect)
End Using