unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 =
class(TForm)
GroupBox1: TGroupBox;
Bild: TImage;
Abbrechen: TButton;
Start: TButton;
procedure AbbrechenClick(Sender: TObject);
procedure StartClick(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.AbbrechenClick(Sender: TObject);
begin
close;
end;
procedure TForm1.StartClick(Sender: TObject);
var a1,a2,a3,a4,a5,a6,b1,b2,b3,b4,b5,b6,xstart,ystart,n,zufall,x,y,anzahl : integer;
begin
with Bild
do
// GRUND-DREICECK ZEICHNEN
begin
randomize;
a1:=220; b1:=500; a2:=720; b2:=500; a3:=920; b3:=250;
a4:=720; b4:=20; a5:=220; b5:=20; a6:=20; b6:=250;
//Dreickes-Koordinaten
canvas.MoveTo(a1,b1);
// "Stift" aufsetzen
canvas.LineTo(a2,b2);
//Zeichen zu ...
canvas.LineTo(a3,b3);
canvas.LineTo(a4,b5);
canvas.LineTo(a5,b5);
canvas.LineTo(a6,b6);
canvas.LineTo(a1,b1);
// Dreieck gezeichnet (done)
// STARTPUNKT SETZEN
xstart:=170; ystart:=400;
canvas.Pixels[xstart,ystart]:=clblack;
n:=0;
// "Regentropfen"
anzahl:=1000000;
repeat
inc(n); zufall:=random(6);
if zufall=0
then begin
x:=(xstart+a1)
div 2; y:=(ystart+b1)
div 2;
canvas.Pixels[x,y]:=clred;
xstart:=x ; ystart:= y ;
end;
if zufall=1
then begin
x:=(xstart+a2)
div 2; y:=(ystart+b2)
div 2 ;
canvas.Pixels[x,y]:=clgreen;
xstart:=x ; ystart:= y ;
end;
if zufall=2
then begin
x:=(xstart+a3)
div 2 ; y:=(ystart+b3)
div 2 ;
canvas.Pixels[x,y]:=clblue;
xstart:=x ; ystart:=y ;
end;
if zufall=3
then begin
x:=(xstart+a4)
div 2 ; y:=(ystart+b4)
div 2 ;
canvas.Pixels[x,y]:=clyellow;
xstart:=x ; ystart:=y ;
end;
if zufall=4
then begin
x:=(xstart+a5)
div 2 ; y:=(ystart+b5)
div 2 ;
canvas.Pixels[x,y]:=clpurple;
xstart:=x ; ystart:=y ;
end;
if zufall=5
then begin
x:=(xstart+a6)
div 2 ; y:=(ystart+b6)
div 2 ;
canvas.Pixels[x,y]:=clsilver;
xstart:=x ; ystart:=y ;
end;
until n=anzahl;
end;
// end of with
end;
end.