//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Rectangle.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
// BeginExample: Rectangle
// Property: Graphics.TCanvas.Rectangle
// Method: Graphics.TPen.Style
// Property: Graphics.TPen.Color

// BeginCode
/*
This example draws many rectangles of various sizes and
colors on a form maximized to fill the entire screen. To run
the code, drop a TTimer component on the form and use the
object inspector to create the OnTimer and OnActivate event
handlers.
*/
int x, y;

void __fastcall TForm1::FormActivate(TObject *Sender)
{
  WindowState = wsMaximized;
  Timer1->Interval = 50;
  randomize();
}

void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
  x = random(Screen->Width - 10);
  y = random(Screen->Height - 10);
  Canvas->Pen->Color = (Graphics::TColor) random(65535);
  switch (random(5))
  {
    case 0: Canvas->Pen->Style = psSolid; break;
    case 1: Canvas->Pen->Style = psDash; break;
    case 2: Canvas->Pen->Style = psDot; break;
    case 3: Canvas->Pen->Style = psDashDot; break;
    case 4: Canvas->Pen->Style = psDashDotDot; break;
  }
  Canvas->Rectangle(x, y, x + random(400), y + random(400));
}
// EndCode
// EndExample: Rectangle
//---------------------------------------------------------------------------
