为什么看到锯齿状曲线? [英] Why do I see this jagged curves?
问题描述
我有一个使用以下代码绘制画布并绘制曲线的代码:
I have a canvas and draw curve with this code:
using (Graphics g = Graphics.FromImage(canvas.BackgroundImage))
{
g.DrawCurve(pen, points);
points
是我填写的数组鼠标位置点。
结果是我看到一些没有画出的锯齿状线。
points
is array that I fill that by mouse location points.
In the result I see some jagged lines that I didn't draw.
您可以在这里看到它们(红色矩形):
You can see them here(in red rectangles):
我该怎么办?
推荐答案
您看到的是 Linejoin
,它是 Mitre
和默认值,用于 MiterLimit
,即10。
What you is see is the somewhat unlucky combination of the default for Linejoin
, which is Miter
and the default for MiterLimit
, which is 10.
相反,您可以选择其他 LineJoin
个选项之一,也可以选择减少 MiterLimit
说少些一半 Pen.Width
..
Instead you have a choice of either picking one of the other LineJoin
options or reducing the MiterLimit
to say less than half the Pen.Width
..
using (Pen myPen = new Pen(Color.Blue, 24f))
{
// either another LineJoine;
myPen.LineJoin = System.Drawing.Drawing2D.LineJoin.Round;
// or a reduced MiterLimit:
myPen.MiterLimit = 1+ myPen.Width / 5f;
}
这篇关于为什么看到锯齿状曲线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!