2010-07-01 65 views
1
時,取出角落

結果:

alt text http://lh4.ggpht.com/_1TPOP7DzY1E/TCyG2pVxi2I/AAAAAAAADSM/TTqZZxh5LR8/s800/Capture4.gif繪製粗線

問:

我璨圓或做這一行 「附錄」 的東西嗎?

代碼:

private void Form1_Paint(object sender, PaintEventArgs e) 
    { 
     Point[] points1 = new Point[] { 
      new Point(50, 90), 
      new Point(60, 20), 
      new Point(70, 120) 
     }; 

     GraphicsPath path1 = new GraphicsPath(); 
     path1.AddLines(points1); 

     ControlPaint.DrawGrid(e.Graphics, this.ClientRectangle, 
      new Size(10, 10), Color.Red); 

     using (Pen p = Pens.DarkBlue.Clone() as Pen) 
     { 
      p.Width = 5; 
      e.Graphics.DrawPath(p, path1); 
      e.Graphics.DrawString("Width: " + p.Width, 
       new Font(this.Font, FontStyle.Bold), 
       Brushes.DarkBlue, new Point(35, 150)); 

      Matrix m = new Matrix(); 
      m.Translate(50, 0); 
      e.Graphics.Transform = m; 

      p.Width = 1; 
      e.Graphics.DrawPath(p, path1); 
      e.Graphics.DrawLine(Pens.Red, -40, 20, 150, 20); 
      e.Graphics.DrawString("Width: " + p.Width, 
       this.Font, Brushes.DarkBlue, new Point(35, 150)); 
     } 
    } 

回答

4

只要改變Pen.LineJoinLineJoin.Round。您還可以降低Pen.MiterLimit來剪輯很長的角落。

+0

謝謝Daniel,這正是我正在尋找的。我使用了'LineJoin.Bevel;' – serhio 2010-07-01 12:57:25

+0

您如何看待Round或Bevel更高效的方法? – serhio 2010-07-01 12:59:24

+0

我不知道 - 描述它。 – 2010-07-01 15:29:56