title: How to draw a shape point by point in C#?
body: <p>I have the basic idea of how it can be done but I don't really know the code. I want to use a WPF application in Visual Studio. When the user clicks a "Draw" button, it would draw a shape (a spirograph), on the canvas (using a polyline) but the twist is, it needs to draw it point by point, one line at a time so you will see this "animation." Also, the user should be able to cancel/stop the drawing while it is being drawn on canvas. First, it will need to generate a list or array of points (I have more familiarity with arrays), then pass the points to a background worker which will "report its progress" by drawing the shape slowly on the canvas. Here is the code for drawing a spirograph but any shape is ok really.</p>
  
  <pre><code>public void DrawSpiroGraph()
  {
      for (inti = 0; i&lt;= numPoints; i++)
      {
          pt = newPoint();
          pt.X = x0 + r * Math.Cos(a);
          pt.Y = y0 + r * Math.Sin(a);
          double rr = 0.5 * r;
          double aa = -0.8 * a;
          Point pnt = newPoint();
          pnt.X = pt.X + rr * Math.Cos(aa);
          pnt.Y = pt.Y + rr * Math.Sin(aa);
          a += 0.5;
          pline.Points.Add(pnt);
      }
  }
  </code></pre>