Registriert seit: 7. Feb 2004
Ort: Werlte
59 Beiträge
Delphi 6 Personal
|
Re: uhr in delphi--> wie die zeiger?
29. Mär 2004, 17:22
würde aber auch anders gehn ohne die procedur berechne_xy
Delphi-Quellcode:
procedure TForm1.Timer1Timer(Sender: TObject);
VAR winkel: Real;
x, y, x1, y1, r, i: Integer;
hour, min, sec, msec: Word;
begin
Form1.Caption := DateTimeToStr(Now);
(*alte Grafik löschen*)
Refresh;
(*Einpssen des Kreises in das Fenster*)
if Width <= Height
then r := Width div 3
else r := Height div 3;
(*Umwandlung in einzelne Integer-Werte*)
DecodeTime(Now, hour, min, sec, msec);
(*Sekundenzeiger*)
winkel := sec * (((2 * pi) / 60)) - pi / 2;
x := Trunc(Cos(winkel)* r);
y := Trunc(Sin(winkel)* r);
x := x + (Width div 2);
y := y + (Height div 2);
Canvas.Moveto(Width div 2, Height div 2);
Canvas.LineTo(x, y);
(*Minutenzeiger*)
winkel := min * (((2 * pi) / 60)) - pi / 2;
x := Trunc(Cos(winkel)* r);
y := Trunc(Sin(winkel)* r);
x := x + (Width div 2);
y := y + (Height div 2);
Canvas.Moveto(Width div 2, Height div 2);
Canvas.LineTo(x, y);
Canvas.Moveto((Width div 2) + 1, (Height div 2) + 1);
Canvas.LineTo(x, y);
Canvas.Moveto((Width div 2) + 1, (Height div 2) - 1);
Canvas.LineTo(x, y);
Canvas.Moveto((Width div 2 - 1), (Height div 2) + 1);
Canvas.LineTo(x, y);
Canvas.Moveto((Width div 2 - 1), (Height div 2) - 1);
Canvas.LineTo(x, y);
(*Stundenzeiger*)
if hour > 12 then hour := hour -12;
winkel := (hour * (2 * pi) / 12) + (min * (2 * pi) / 720) - pi / 2;
x := Trunc(Cos(winkel)* r * 0.61);
y := Trunc(Sin(winkel)* r * 0.61);
x := x + (Width div 2);
y := y + (Height div 2);
Canvas.Moveto(Width div 2, Height div 2);
Canvas.LineTo(x, y);
Canvas.Moveto((Width div 2) + 1, (Height div 2) + 1);
Canvas.LineTo(x, y);
Canvas.Moveto((Width div 2) + 1, (Height div 2) - 1);
Canvas.LineTo(x, y);
Canvas.Moveto((Width div 2 - 1), (Height div 2) + 1);
Canvas.LineTo(x, y);
Canvas.Moveto((Width div 2 - 1), (Height div 2) - 1);
Canvas.LineTo(x , y);
Canvas.Moveto((Width div 2) + 2, (Height div 2) + 2);
Canvas.LineTo(x, y);
Canvas.Moveto((Width div 2) + 2, (Height div 2) - 2);
Canvas.LineTo(x , y);
Canvas.Moveto((Width div 2 - 2), (Height div 2) + 2);
Canvas.LineTo(x, y);
Canvas.Moveto((Width div 2 - 2), (Height div 2) - 2);
Canvas.LineTo(x , y);
(*Mittelpunkt*)
Canvas.Ellipse((Width div 2)-4, (Height div 2)-4,(Width div 2)+ 4,(Height div 2)+ 4);
(*Ziffernstriche*)
i := 0;
FOR i := 0 TO 11 DO
begin
winkel := i * (((2 * pi) / 12)) - pi / 2;
x := Trunc(Cos(winkel)* 1.1*r);
x1 := Trunc(Cos(winkel)* r);
y := Trunc(Sin(winkel)* 1.1*r);
y1 := Trunc(Sin(winkel)* r);
x := x + (Width div 2);
x1 := x1 + (Width div 2);
y := y + (Height div 2);
y1 := y1 + (Height div 2);
Canvas.Moveto(x, y);
Canvas.LineTo(x1, y1);
end;
(*Minutenpunkte*)
i := 0;
FOR i := 0 TO 59 DO
begin
winkel := i * (((2 * pi) / 60)) - pi / 2;
x := Trunc(Cos(winkel)* 1.1*r);
y := Trunc(Sin(winkel)* 1.1*r);
x := x + (Width div 2);
y := y + (Height div 2);
Canvas.Pixels[x, y] := clRed;
Canvas.Ellipse(x-2, y-2,x+2,y+2);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
DoubleBuffered := True;
end;
end.
1, 2 Billy kommt vorbei.. 3, 4 er steht vor deiner Firma.. 5, 6 gleich holt dich der Ruin.. 7, 8 es ist gleich aus für dich.. 9, 10 deine Firma gehört jetzt M$
|