0
我正在编写一个绘画程序。画线宽度与椭圆宽度
当用户画一条线时,我使用这段代码,它按预期工作。
_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
但是,当用户绘制一个点而不是一条线时,DrawLine不起作用。 因此我使用DrawEllipse。
但是,绘制的椭圆的宽度/高度似乎不可预测,我只是无法确定正确的公式。 单点宽度/高度看起来像是线宽的80%。
这是我使用的是什么
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
有谁似乎是我做错了吗?
此外,我的椭圆不填充,但我想这是另一个问题。
'g.FillEllipse(...' – LarsTech
@LarsTech已经解决了所有的奇怪的问题,你可以让你的评论的答案? – tmighty
我只评论了“这是另一个问题”,我不确定如何解决你的维度问题。 – LarsTech