unit DemoFrm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
TDemoForm =
class(TForm)
Sonne: TShape;
Timer: TTimer;
procedure TimerTimer(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
a, b: Integer;
// Elipsen-Radien
x0, y0: Integer;
// Elipsen-Zentrum
t: Integer;
// Winkel in Grad
procedure MoveShape(t: Integer);
end;
var
DemoForm: TDemoForm;
implementation
{$R *.dfm}
uses
Math;
procedure TDemoForm.MoveShape(t: Integer);
var
x, y: Integer;
begin
x := Round(x0 + a * Cos(DegToRad(t)));
y := Round(y0 - b * Sin(DegToRad(t)));
Sonne.Left := x - Sonne.Width
div 2;
Sonne.Top := y - Sonne.Height
div 2;
end;
procedure TDemoForm.TimerTimer(Sender: TObject);
begin
MoveShape(t);
t := (t + 179)
mod 180;
end;
procedure TDemoForm.FormCreate(Sender: TObject);
begin
DoubleBuffered := True;
a := (ClientWidth - Sonne.Width)
div 2;
b := (ClientHeight - Sonne.Height)
div 2;
x0 := ClientWidth
div 2;
y0 := ClientHeight
div 2;
t := 180;
end;
end.