2010-07-01 3 views
1

Résultat:

alt text http://lh4.ggpht.com/_1TPOP7DzY1E/TCyG2pVxi2I/AAAAAAAADSM/TTqZZxh5LR8/s800/Capture4.gifRetirer les coins lors du dessin des lignes épaisses

Question:

Puis-je contourner ou faire quelque chose avec cette ligne "annexe"?

code:

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)); 
     } 
    } 

Répondre

4

il suffit de changer Pen.LineJoin à LineJoin.Round. Vous pouvez également réduire Pen.MiterLimit pour couper des coins très longs.

+0

Merci, Daniel, c'est exactement ce que je cherchais. J'ai utilisé 'LineJoin.Bevel;' – serhio

+0

Comment pensez-vous, quelle méthode Round ou Bevel est plus performant? – serhio

+0

Je n'ai aucune idée - profil. –

Questions connexes