【问题标题】:Why do I see this jagged curves?为什么我会看到这条锯齿状曲线?
【发布时间】:2016-03-18 12:20:21
【问题描述】:

我有一个画布并使用此代码绘制曲线:

using (Graphics g = Graphics.FromImage(canvas.BackgroundImage))
{
    g.DrawCurve(pen, points);

points 是我通过鼠标位置点填充的数组。 结果我看到了一些我没有画的锯齿状线条。

你可以在这里看到它们(红色矩形):

我该怎么办?

【问题讨论】:

标签: c# winforms graphics curve


【解决方案1】:

您看到的是 Linejoindefault(即 Miter)和 MiterLimitdefault(即 10)的不幸组合.

相反,您可以选择选择其他LineJoin 选项之一,或者将MiterLimit 减少到少于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;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-03-21
    • 2013-01-02
    • 2011-02-04
    • 2017-02-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多