Recent Posts
Selamat datang di Coding Delphi Land Weblog kumpulan source code pemogram delphi
(Bukan maksud untuk menggurui tetapi marilah kita berbagi ilmu tuk perkembangan kemajuan teknologi kita
Sabtu, 14 November 2009
Rotate Around Point
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
TForm1 = class(TForm)
Shape1: TShape;
Timer1: TTimer;
Shape2: TShape;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
X : real;
Y : real;
Angle : real;
Radius : real;
centerX : integer;
centerY : integer;
i : integer;
RadiusY : real;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Radius := 150;
Radiusy := 75;
Angle := 10;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
centerX := (Form1.Left + 400) div 2;
centerY := (Form1.Top + 100);
{shape1:}
Angle := Angle + 1;
X := Int(Radius * cos(Angle * (Pi) / 180) + centerX);
Y := Int(Radius * -sin(Angle * (Pi) / 180) + centerY);
shape1.Top := StrToInt( FloatToStr(Y) );
shape1.left := StrToInt( FloatToStr(X) );
{shape2:}
X := Int(Radius * cos(Angle * (Pi) / 180) + centerX);
Y := Int(Radius * sin(Angle * (Pi) / 180) + centerY);
shape2.Top := StrToInt( FloatToStr(Y) );
shape2.left := StrToInt( FloatToStr(X) );
end;
end.
0 komentar:
Posting Komentar