RoundRect (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example draws many rounded rectangles of various sizes and colors on a form maximized to fill the entire screen.

Code

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);
  Canvas->Pen->Width = random(7);
  int Dx = random(400);
  int Dy = random(400);
  Canvas->RoundRect(x, y, x + Dx, y + Dy, Dx/2, Dy/2);
}

Uses