unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls; type TForm1 = class(TForm) Timer1: TTimer; StartB: TButton; StopB: TButton; PaintBox1: TPaintBox; procedure FormCreate(Sender: TObject); procedure StartBClick(Sender: TObject); procedure StopBClick(Sender: TObject); procedure Timer1Timer(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; y,x:integer; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); begin y:=0; end; procedure TForm1.StartBClick(Sender: TObject); begin Timer1.Enabled:=True; end; procedure TForm1.StopBClick(Sender: TObject); begin Timer1.Enabled:=False end; procedure TForm1.Timer1Timer(Sender: TObject); begin if y=0 then x:=random (PaintBox1.Width); if ((PaintBox1.Canvas.Pixels[x,y+1]=clWhite) or (y = PaintBox1.Height)) then begin PaintBox1.Canvas.Pixels[x,y]:=clWhite; y:=0; end else begin PaintBox1.Canvas.Pixels[x,y]:=clHighlight; y:=y+1; PaintBox1.Canvas.Pixels[x,y]:=clWhite; end; end; end. |