title: Generating Continuous sine/cosine waveform in C#
body: <p>Hey Friend i am trying to generate a continuous sine waveform in C#, i am able to generate only one cycle but i want the waveform to be generated continuous.</p>
  
  <p>Here is my code..</p>
  
  <pre><code>public partial class Form1 : Form
  {
  
      public Form1()
      {
          InitializeComponent();
      }
  
  
      protected override void OnPaint(PaintEventArgs e)
      {
          float x0 = 100f;
          float y0 = 100f;
          PointF[] points = new PointF[200];
  
          for (int j = 0; j &lt; 200; j++)
          {
              points[j] = new PointF();
              points[j].X = x0 + j;
              points[j].Y = y0 - (float)(Math.Sin((2 * Math.PI * j) / 200) * (200 / (2 * Math.PI)));
          }
  
          using (Pen p = new Pen(Color.Blue))
          {
              p.EndCap = LineCap.ArrowAnchor;
  
              //Draw X-coordinate
              e.Graphics.DrawLine(p, x0, y0, x0 + 250, y0);
  
             //Draw Y-coordinate
             e.Graphics.DrawLine(p, x0, y0 + 80, x0, y0 - 80);
          }
  
          e.Graphics.DrawString("0", SystemFonts.DefaultFont, Brushes.Blue, x0, y0 );
          e.Graphics.DrawString("p", SystemFonts.DefaultFont, Brushes.Blue, x0 + 100, y0);
          e.Graphics.DrawString("2p", SystemFonts.DefaultFont, Brushes.Blue, x0 + 200, y0);
  
          e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
          e.Graphics.DrawLines(Pens.Blue, points);
          base.OnPaint(e);
      }
  }
  </code></pre>