为什么我会看到这个锯齿状的曲线? [英] 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
,即斜接
和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屋!
查看全文