title: How to draw Bezier-Curve C#
body: <p>I need to draw an bezier curve. But the problem is my code bring this output:</p>
  
  <p><a href="https://i.stack.imgur.com/1GFJp.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1GFJp.jpg" alt=""></a></p>
  
  <p>But it should look like this:</p>
  
  <p><a href="https://i.stack.imgur.com/3i6BV.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3i6BV.jpg" alt=""></a></p>
  
  <p>How can i "delete" the rest of the lines. I don't know how tho draw the control polygon only on his finest Level of polyline.</p>
  
  <pre><code>    private void pb_Bezier_Paint(object sender, PaintEventArgs e)
      {
          Point P1 = new Point(10, 300);
          Point P2 = new Point(180, 50);
          Point P3 = new Point(320, 300);
  
          ZeichneBezier(6, P1, P2, P3, e);
      }
  
      private void ZeichneBezier(int n, Point P1, Point P2, Point P3, PaintEventArgs pva)
      {
          Graphics g = pva.Graphics;
          Pen kpStift = new Pen(Color.Black, 3);
          Pen bkStift = new Pen(Color.Red, 2);
  
          for(int i = n; i &gt;= 0; i--)
          {
              if(i==0)
              {
                  g.DrawLine(bkStift, P1, P2);
                  g.DrawLine(bkStift, P2, P3);
              }
              else
              {
                  Point P12 = new Point((P1.X + P2.X)/2,(P1.Y + P2.Y)/2);
                  Point P23 = new Point((P2.X + P3.X)/2,(P2.Y + P3.Y)/2);
                  Point P123 = new Point((P12.X + P23.X)/2,(P12.Y + P23.Y)/2);
  
                  ZeichneBezier(n-1, P1, P12, P123, pva);
                  ZeichneBezier(n-1, P123, P23, P3, pva);
              }
          }
  </code></pre>