unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
TRectInfo=Record
Farbe : TColor;
Bounds : TRect;
End;
TRectInfoArray=Array
of TRectInfo;
TForm1 =
class(TForm)
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure FormPaint(Sender: TObject);
private
{ Private-Deklarationen }
FRectInfoArray:TRectInfoArray;
procedure AddOneRect;
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
const
C_Size=100;
{$R *.dfm}
procedure TForm1.AddOneRect;
var
idx:Integer;
begin
SetLength(FRectInfoArray, High(FRectInfoArray) + 2);
idx := High(FRectInfoArray);
FRectInfoArray[idx].Farbe := Random(clWhite);
FRectInfoArray[idx].Bounds.Left := Random(Width - C_Size);
FRectInfoArray[idx].Bounds.Top := Random(Height - C_Size);
FRectInfoArray[idx].Bounds.Right := FRectInfoArray[idx].Bounds.Left + Random(C_Size);
FRectInfoArray[idx].Bounds.Bottom := FRectInfoArray[idx].Bounds.Top + Random(C_Size);
invalidate;
end;
procedure TForm1.FormPaint(Sender: TObject);
var
i:Integer;
begin
for I := Low(FRectInfoArray)
to High(FRectInfoArray)
do
begin
Canvas.Brush.Color := FRectInfoArray[i].Farbe;
Canvas.Rectangle(FRectInfoArray[i].Bounds.Left, Height - FRectInfoArray[i].Bounds.top,FRectInfoArray[i].Bounds.Right, Height - FRectInfoArray[i].Bounds.Bottom);
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
AddOneRect;
end;
end.