langkah awal buka delphi
buat sebuah form dan tambah komponen seperti gambar yang di atas
Masukan koding pada setiap komponen yang telah anda tambahkan pada form
unit AnimasiCurpa2U;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Shape1: TShape;
Timer1: TTimer;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
r,d,c,x,y,theta,thetaf:real;
a,xc,yc,b,xp:integer;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
a:=100;xc:=300;yc:=200;b:=100;
thetaf:=0.0;
d:=2*PI;xp:=0;
theta:=d;
c:=1/a; timer1.Enabled:=true;
shape1.Visible:=false;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if (thetaf<(8*theta))then
begin
r:=b*sin(thetaf)+sin(thetaf)/cos(thetaf);
x:=r*cos(5*thetaf);
y:=r*sin(7*thetaf);
if xp=0 then
canvas.Pixels[trunc(xc+x),trunc(yc+y)]:=clred;
if xp=1then
begin
shape1.Left:=trunc(xc+x);
shape1.Top:=trunc(yc+y);
end;
thetaf:=thetaf+c;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
xp:=1;
shape1.Visible:=true;
a:=100; xc:=300; yc:=200; b:=100;
thetaf:=0.0;
d:=2*PI;
theta:=d;
c:=1/a; timer1.Enabled:=true;
end;
end.
Semoga bermanfaat jangan lupa komennya





3:38:00 PM
seppriatna

Posted in: 
