Bezier Art : Graphics : Graphics C# Source Code


Custom Search

C# Source Code » Graphics » Graphics »

 

Bezier Art








    
 


using System;
using System.Drawing;
using System.Windows.Forms;
   
class BezierArt: Form
{
   
     public static void Main()
     {
          Application.Run(new BezierArt());
     }
     public BezierArt()
     {
          ResizeRedraw = true; 
     }
     protected override void OnPaint(PaintEventArgs pea)
     {
          DoPage(pea.Graphics, ForeColor,200, 200);
     }       
     protected void DoPage(Graphics grfx, Color clr, int cx, int cy)
     {
          Pen      pen  = new Pen(clr);
          PointF[] aptf = new PointF[4];
   
          int iNum = 100;
 
          for (int i = 0; i < iNum; i++)
          {
               double dAngle = 2 * i * Math.PI / iNum;
   
               aptf[0].X =     cx / 2 + cx /  2 * (float) Math.Cos(dAngle);
               aptf[0].Y = 5 * cy / 8 + cy / 16 * (float) Math.Sin(dAngle);
   
               aptf[1] = new PointF(cx / 2,    -cy);
               aptf[2] = new PointF(cx / 2, 2 * cy);
   
               dAngle += Math.PI;
   
               aptf[3].X = cx / 2 + cx /  4 * (float) Math.Cos(dAngle);
               aptf[3].Y = cy / 2 + cy / 16 * (float) Math.Sin(dAngle);
   
               grfx.DrawBeziers(pen, aptf);
          }
     }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Graphics
» Graphics