blikk info infothek forum galerie sitemap

CS-Zufallsfarben und Zufallszahlen

zur Aufgabenstellung
Lösung 1:

 

 

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Buttons, ExtCtrls;

type
  TForm1 = class(TForm)
    BitBtn1: TBitBtn;
    Timer1: TTimer;
    Label1: TLabel;
    procedure symbol;
    procedure Timer1Timer(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;


implementation

{$R *.DFM}

procedure tform1.symbol;

var
 c1, c2, c3: Integer;


begin
 randomize;
 c1:=Random(256);
 c2:=Random(256);
 c3:=Random(256);


with form1.canvas do begin
pen.color:=clsilver;
pen.width:=4;
moveto(penpos.x,penpos.y);
lineto(penpos.x+5,penpos.y+10);
lineto(penpos.x+10,penpos.y+5);
lineto(penpos.x-10,penpos.y+5);
lineto(penpos.x-5,penpos.y+10);
lineto(penpos.x-5,penpos.y-10);
lineto(penpos.x-10,penpos.y-5);
lineto(penpos.x+10,penpos.y-5);
lineto(penpos.x+5,penpos.y-10);
brush.color:=RGB(c1, c2, c3);
floodfill(penpos.x,penpos.y+5,clsilver,fsborder);
//Stern
end;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
randomize;
with form1.canvas do begin
symbol;
moveto(round(random*form1.width),round(random*form1.height));

//Position des Sterns
end;
end;

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
with form1.canvas do begin
timer1.enabled:=true;
//Aktivierung des Timers
end;
end;

end.

Lösung 2:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Buttons, ExtCtrls, jpeg, MPlayer;


type
  TForm1 = class(TForm)
    BitBtn1: TBitBtn;
    Timer1: TTimer;
    Shape1: TShape;
    Shape2: TShape;
    Shape3: TShape;
    Shape4: TShape;
    Shape5: TShape;
    Shape6: TShape;
    Shape7: TShape;
    Shape8: TShape;
    Shape9: TShape;
    Shape10: TShape;
    Shape12: TShape;
    Shape11: TShape;
    Shape14: TShape;
    Shape13: TShape;
    Timer2: TTimer;
    Image1: TImage;
    Label1: TLabel;
    Label2: TLabel;
    Shape15: TShape;
    Shape16: TShape;
    Shape17: TShape;
    Shape18: TShape;
    Shape19: TShape;
    Shape20: TShape;
    Shape21: TShape;
    Shape22: TShape;
    Shape23: TShape;
    Shape24: TShape;
    Shape25: TShape;
    Shape26: TShape;
    Shape27: TShape;
    Shape28: TShape;
    Shape29: TShape;
    Shape30: TShape;
    Shape31: TShape;
    Shape32: TShape;
    Shape33: TShape;
    Shape34: TShape;
    Shape35: TShape;
    Shape36: TShape;
    Shape37: TShape;
    Shape38: TShape;
    Shape39: TShape;
    Shape40: TShape;
    Shape41: TShape;
    Timer3: TTimer;
    Shape42: TShape;
    Shape45: TShape;
    Shape46: TShape;
    Shape47: TShape;
    Shape48: TShape;
    Shape49: TShape;
    Timer4: TTimer;
    procedure BitBtn1Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure Timer2Timer(Sender: TObject);
    procedure Timer3Timer(Sender: TObject);
    procedure Timer4Timer(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;


var
  Form1: TForm1;


implementation

{$R *.DFM}

procedure TForm1.Bitbtn1Click(Sender: TObject);
begin
timer1.enabled:=true;
timer2.enabled:=true;
timer3.enabled:=true;
timer4.enabled:=true;
//mediaplayer1.open;
//mediaplayer1.play;
end;



procedure TForm1.Timer1Timer(Sender: TObject);
var
 c1, c2, c3: Integer;

begin
 c1:=Random(256);
 c2:=Random(256);
 c3:=Random(256);


 shape1.brush.Color:=RGB(c1, c2, c3);
 shape2.brush.Color:=RGB(c1, c2, c3);
 shape3.brush.Color:=RGB(c1, c2, c3);
 shape4.brush.Color:=RGB(c1, c2, c3);
 shape5.brush.Color:=RGB(c1, c2, c3);
 shape6.brush.Color:=RGB(c1, c2, c3);
 shape7.brush.Color:=RGB(c1, c2, c3);
 shape8.brush.Color:=RGB(c1, c2, c3);

end;


procedure TForm1.Timer2Timer(Sender: TObject);
var
 c1, c2, c3: Integer;
begin
 c1:=Random(256);
 c2:=Random(256);
 c3:=Random(256);


 shape9.brush.Color:=RGB(c1, c2, c3);
 shape10.brush.Color:=RGB(c1, c2, c3);
 shape11.brush.Color:=RGB(c1, c2, c3);
 shape12.brush.Color:=RGB(c1, c2, c3);
 shape13.brush.Color:=RGB(c1, c2, c3);
 shape14.brush.Color:=RGB(c1, c2, c3);
 label1.font.Color:=RGB(c1, c2, c3);
 label2.font.Color:=RGB(c1, c2, c3);
 bitbtn1.font.Color:=RGB(c1, c2, c3);

end;


procedure TForm1.Timer3Timer(Sender: TObject);
var
 c1, c2, c3: Integer;
begin
 c1:=Random(256);
 c2:=Random(256);
 c3:=Random(256);

 shape15.brush.Color:=RGB(c1, c2, c3);
 shape16.brush.Color:=RGB(c1, c2, c3);
 shape17.brush.Color:=RGB(c1, c2, c3);
 shape18.brush.Color:=RGB(c1, c2, c3);
 shape19.brush.Color:=RGB(c1, c2, c3);
 shape20.brush.Color:=RGB(c1, c2, c3);
 shape21.brush.Color:=RGB(c1, c2, c3);
 shape22.brush.Color:=RGB(c1, c2, c3);
 shape23.brush.Color:=RGB(c1, c2, c3);
 shape24.brush.Color:=RGB(c1, c2, c3);
 shape25.brush.Color:=RGB(c1, c2, c3);
 shape26.brush.Color:=RGB(c1, c2, c3);
 shape27.brush.Color:=RGB(c1, c2, c3);
 shape28.brush.Color:=RGB(c1, c2, c3);
 shape29.brush.Color:=RGB(c1, c2, c3);
 shape30.brush.Color:=RGB(c1, c2, c3);
 shape31.brush.Color:=RGB(c1, c2, c3);
 shape32.brush.Color:=RGB(c1, c2, c3);
 shape33.brush.Color:=RGB(c1, c2, c3);
 shape34.brush.Color:=RGB(c1, c2, c3);
 shape35.brush.Color:=RGB(c1, c2, c3);
 shape36.brush.Color:=RGB(c1, c2, c3);
 shape37.brush.Color:=RGB(c1, c2, c3);
 shape38.brush.Color:=RGB(c1, c2, c3);
 shape39.brush.Color:=RGB(c1, c2, c3);
 shape40.brush.Color:=RGB(c1, c2, c3);
 shape41.brush.Color:=RGB(c1, c2, c3);
 shape42.brush.Color:=RGB(c1, c2, c3);
 shape45.brush.Color:=RGB(c1, c2, c3);
 shape46.brush.Color:=RGB(c1, c2, c3);
 shape47.brush.Color:=RGB(c1, c2, c3);
 shape48.brush.Color:=RGB(c1, c2, c3);
 shape49.brush.Color:=RGB(c1, c2, c3);


end;

procedure TForm1.Timer4Timer(Sender: TObject);
var
c1, c2, c3: Integer;
begin
{with form1.canvas do begin
 c1:=Random(256);
 c2:=Random(256);
 c3:=Random(256);
 pen.width:=1;
 pen.Color:=RGB(c1, c2, c3);
 moveto(penpos.x+380,penpos.y+100);
 lineto(penpos.x+450,penpos.y+80);


end;}

end;

end.

 

 
nach oben
punkt   seitenbereich schließen

Seitentitel

AS-Zufallsfarben und Zufallszahlen

TS- Zufallsfarben und Zufallszahlen

Das Programm
1