procedure TForm1.FormCreate(Sender: TObject);
begin
Timer1.Interval := 50;
iPosX := 0;
bmp := TBitmap.Create;
bmp.Width := PaintBox1.Width;
bmp.Height := PaintBox1.Height;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Timer1.Enabled :=
not Timer1.Enabled;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var
val: Integer;
begin
Application.ProcessMessages;
if iPosX >= PaintBox1.Width
then
Dec(iPosX);
val := RandomRange(25, 45);
bmp.Canvas.MoveTo(iPosX, bmp.Height - val);
bmp.Canvas.LineTo(iPosX, bmp.Height);
Inc(iPosX);
PaintBox1.Repaint;
end;
procedure TForm1.PaintBox1Paint(Sender: TObject);
begin
TPaintBox(Sender).Canvas.Draw(0, 0, bmp);
end;