unit Main;
interface
uses
System.Types, Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs, Direct2D,
Vcl.StdCtrls,
Vcl.ExtCtrls;
type
TForm1 =
class(TForm)
Label1: TLabel;
Timer1: TTimer;
Label2: TLabel;
procedure FormPaint(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private-Deklarationen }
FD2DCanvas : TDirect2DCanvas;
FAngle : integer;
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
// Funktion um die Endkoordinaten auszurechnen
function Polar(X, Y, Length, Angle: integer): TPoint;
begin
Result := Point(Round(cos(Angle)*Length+X), Round(sin(Angle)*Length+Y));
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FAngle := 0;
end;
procedure TForm1.FormPaint(Sender: TObject);
begin
FD2DCanvas := TDirect2DCanvas.Create(Canvas, ClientRect);
FD2DCanvas.BeginDraw;
try
FD2DCanvas.DrawLine(Point(100,100), Polar(100,100,50,FAngle));
finally
FD2DCanvas.EndDraw;
FD2DCanvas.Free;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
inc(FAngle);
if FAngle = 360
then
FAngle := 0;
Label1.Caption := inttostr(FAngle);
Invalidate;
end;
end.