RoundRect (Delphi)

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

var
  X, Y, DX, DY: Integer;
procedure TForm1.FormActivate(Sender: TObject);
begin
  WindowState := wsMaximized;
  Timer1.Interval := 50;
  Randomize;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  X := Random(Screen.Width - 10);
  Y := Random(Screen.Height - 10);
  Canvas.Pen.Color := Random(65535);
  Canvas.Pen.Width := Random(7);
  DX := Random(400);
  DY := Random(400);
  Canvas.RoundRect(X, Y, X + DX, Y + DY, DX div 2, DY div 2);
end;

Uses