blikk info infothek forum galerie sitemap

Lösung

zur Aufgabenstellung

unit Unit1;

 

interface

 

uses

  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

  StdCtrls;

 

type

  TForm1 = class(TForm)

    Button1: TButton;

    procedure Button1Click(Sender: TObject);

    procedure Olympia;

  private

    { Private-Deklarationen }

  public

    { Public-Deklarationen }

  end;

 

var

  Form1: TForm1;

 

implementation

 

{$R *.DFM}

procedure TForm1.Olympia;

begin

with Form1.canvas do begin

brush.style:=bsclear;

pen.width:=3;    //Breite des Stifts

 

pen.color:=clblue;

ellipse(penpos.x,penpos.y,penpos.x+20,penpos.y+20); //Ring links oben

 

pen.color:=clblack;

moveto(penpos.x+22,penpos.y);

ellipse(penpos.x,penpos.y,penpos.x+20,penpos.y+20); // Ring oben Mitte

 

pen.color:=clred;

moveto(penpos.x+22,penpos.y);

ellipse(penpos.x,penpos.y,penpos.x+20,penpos.y+20); // Ring oben rechts

 

pen.color:=clyellow;

moveto(penpos.x-34,penpos.y+10);

ellipse(penpos.x,penpos.y,penpos.x+20,penpos.y+20); // Ring unten links

 

pen.color:=clgreen;

moveto(penpos.x+22,penpos.y);

ellipse(penpos.x,penpos.y,penpos.x+20,penpos.y+20); // Ring unten rechts

end

end;

 

//aktuelle Position des Stifts ist jetzt links oben am grünen Ring!

 

procedure TForm1.Button1Click(Sender: TObject);

begin

with Form1.Canvas do begin

moveto(400,0); // Mitte des Fenster, ganz oben

while penpos.y < Form1.height do begin

olympia;

moveto(penpos.x-32,penpos.y+30);

// x = Breite des gelben Rings (20)

       + Abstand (2)

       + halbe Breite des blauen Rings (10) = 32

// y = Höhe des Rings (20) + Abstand (10) = 30

end

end

end;

end.

 

Delphi 

 

zurück zur Theorie

 

 

 

nach oben