Graphics : Graphics : Graphics C# Source Code


Custom Search

C# Source Code » Graphics » Graphics »

 

Graphics








    
 


using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
   
class RotatedRectangles: Form
{
     public static void Main()
     {
          Application.Run(new RotatedRectangles());
     }
     public RotatedRectangles()
     {
          Text = "Rotated Rectangles";
          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)
     {
          Pen      pen   = new Pen(clr);
          grfx.PageUnit  = GraphicsUnit.Pixel;
          PointF[] aptf  = { (PointF) grfx.VisibleClipBounds.Size };
          grfx.PageUnit  = GraphicsUnit.Inch;
          grfx.PageScale = 0.01f;
   
          grfx.TransformPoints(CoordinateSpace.Page, 
                               CoordinateSpace.Device, aptf);
   
          grfx.TranslateTransform(aptf[0].X / 2, aptf[0].Y / 2);
          
          for (int i = 0; i < 6; i++)
          {
               grfx.DrawRectangle(pen, 0, 0, 200, 200);
               grfx.RotateTransform(10);
          }
     }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Graphics
» Graphics