Einzelnen Beitrag anzeigen

hathor
(Gast)

n/a Beiträge
 
#6

Re: Stern zeichnen mit line to und move to

  Alt 25. Okt 2009, 15:11
Ich habe hier was Schönes gefunden:
Es zeichnet eine EU-Flagge mit 12 (!) Sternen:

Delphi-Quellcode:
procedure drawstar( xc, yc: integer; radius:double);
var data : array[1..10] of Tpoint;
    j : integer; a: double;
begin
    for j := 0 to 4 do begin
        with data[2*j+1] do begin
            a := 2*pi*j/5;
            x := xc + round(radius*sin(a));
            y := yc - round(radius*cos(a));
            end;
        with data[2*j+2] do begin
            a := 2*pi*(j+0.5)/5;
            x := xc + round(0.4*radius*sin(a));
            y := yc - round(0.4*radius*cos(a));
            end;
        end;
    Form1.canvas.polygon(data);
end;

procedure TForm1.FormPaint(Sender: TObject);
var j, h,w, r, n: integer; a: double;
begin with canvas do begin
    h := Form1.clientheight;
    w := Form1.clientwidth;
    brush.color := clblue;
    rectangle(0,0,w,h);
    r := (2*h) div 6;
    n := 12;
    {15 EU countries - 1999,
    but flag fixed at 12
    data from EU publicity map 1999}

    brush.color := clyellow;
    for j := 0 to n do begin
        a := 2*pi*j/n;
        drawstar( w div 2 + round( r * sin(a)),
                   h div 2 + round( r * cos(a)),
                   (4*h) div 100);
        end;{for}
    end; {with}
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
   FormPaint(Self);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
 // 1 Stern mit 5 Zacken
 drawstar(150,150,150);
end;
  Mit Zitat antworten Zitat