Spiral : Curve : Graphics C# Source Code


Custom Search

C# Source Code » Graphics » Curve »

 

Spiral








    
 

using System;
using System.Drawing;
using System.Windows.Forms;
   
class Spiral: Form
{
     public static void Main()
     {
          Application.Run(new Spiral());
     }
     public Spiral()
     {
          ResizeRedraw = true;
     }
     protected override void OnPaint(PaintEventArgs pea)
     {
          DoPage(pea.Graphics, ForeColor,ClientSize.Width, ClientSize.Height);
     }
     protected void DoPage(Graphics grfx, Color clr, int cx, int cy)
     {
          const int iNumRevs   = 20;
          int       iNumPoints = iNumRevs * 2 * (cx + cy);
          PointF[]  aptf       = new PointF[iNumPoints];
          float     fAngle, fScale;
   
          for (int i = 0; i < iNumPoints; i++)
          {
               fAngle = (float)(i * 2 * Math.PI /(iNumPoints / iNumRevs));
               fScale = 1 - (float)i / iNumPoints;
   
               aptf[i].X = (float)(cx / 2 * (1 + fScale * Math.Cos(fAngle)));
               aptf[i].Y = (float)(cy / 2 * (1 + fScale * Math.Sin(fAngle)));
          }
          grfx.DrawLines(new Pen(clr), aptf);
     }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Graphics
» Curve