代码之家  ›  专栏  ›  技术社区  ›  oliver

带图形的尖角。绘图线[副本]

  •  0
  • oliver  · 技术社区  · 7 年前

    我有一个画布,用这个代码绘制曲线:

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

    points 是由鼠标位置点填充的数组。 结果我看到一些我没有画的参差不齐的线。

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

    enter image description here

    我能怎么办?

    0 回复  |  直到 10 年前
        1
  •  2
  •   TaW    10 年前

    你看到的是一些不幸的组合 违约 对于 Linejoin ,这是 Miter 违约 对于 MiterLimit

    相反,你可以选择其中一个 LineJoin 选择或减少 米特里米特 不到一半 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;
    }
    
    推荐文章