Pertama anda jalankan Delphi 6.0
Jadikan Form delphi seperti gambar di bawah ini
Setiap komponen tambah koding seperti di bawah ini ::
unit AnimasiKurvaU;
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)/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;
if (thetaf>(8*theta))then
begin
r:=b+sin(thetaf)/cos(sqr(thetaf));
x:=r*cos(thetaf);
y:=r*sin(thetaf);
if xp=0 then
canvas.Pixels[trunc(xc+x),trunc(yc+y)]:=clred;
if xp=1 then
begin
shape1.Left:=trunc(xc+x);
shape1.Left:=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;
thetaf:=d;
c:=1/a; timer1.Enabled:=true;
end;
end.
SEMOGA BERMANFAAT
Jadikan Form delphi seperti gambar di bawah ini
Setiap komponen tambah koding seperti di bawah ini ::
unit AnimasiKurvaU;
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)/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;
if (thetaf>(8*theta))then
begin
r:=b+sin(thetaf)/cos(sqr(thetaf));
x:=r*cos(thetaf);
y:=r*sin(thetaf);
if xp=0 then
canvas.Pixels[trunc(xc+x),trunc(yc+y)]:=clred;
if xp=1 then
begin
shape1.Left:=trunc(xc+x);
shape1.Left:=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;
thetaf:=d;
c:=1/a; timer1.Enabled:=true;
end;
end.
SEMOGA BERMANFAAT
1 komentar:
ok ok,, thanks infonya :)
Posting Komentar