Selasa, 09 Oktober 2012
ALGORITMA TREELEAF 2
OKE.....HARI INI saya membahas mengenai program grafika komputer tentang algoritma treeleaf bagian 2........(MENGGUNAKAN DELPHI 7)
klik 2 x pada tombol button 1...dan copy listing program berikut:
procedure TForm1.Button1Click(Sender: TObject);
var r,d,e,c,x,y,z,theta,thetf: real;
a,xc,yc:integer;
begin
a:=144;
xc:=300;
yc:=300;
thetf:=10.10;
d:=25*PI;
e:=6*cos(45*thetf);
theta:=a+d+e;
c:=1/a;
while (thetf<theta) do
begin
r:=(a*cos(theta))+sin(thetf)/cos(theta)+200*sin(30*thetf);
x:=d+r*cos(thetf);
y:=a-r*cos(theta);
canvas.pixels[trunc(xc+x),trunc(yc+y)]:=clwhite;
canvas.pixels[trunc(xc-x),trunc(yc+y)]:=clwhite;
canvas.pixels[trunc(xc+x),trunc(yc-y)]:=clwhite;
canvas.pixels[trunc(xc-x),trunc(yc-y)]:=clwhite;
thetf:=thetf+c;
end;
end;
end.
cek ulang lagi,dan samakan dengan yang dibawah ini....
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var r,d,e,c,x,y,z,theta,thetf: real;
a,xc,yc:integer;
begin
a:=144;
xc:=300;
yc:=300;
thetf:=10.10;
d:=25*PI;
e:=6*cos(45*thetf);
theta:=a+d+e;
c:=1/a;
while (thetf<theta) do
begin
r:=(a*cos(theta))+sin(thetf)/cos(theta)+200*sin(30*thetf);
x:=d+r*cos(thetf);
y:=a-r*cos(theta);
canvas.pixels[trunc(xc+x),trunc(yc+y)]:=clwhite;
canvas.pixels[trunc(xc-x),trunc(yc+y)]:=clwhite;
canvas.pixels[trunc(xc+x),trunc(yc-y)]:=clwhite;
canvas.pixels[trunc(xc-x),trunc(yc-y)]:=clwhite;
thetf:=thetf+c;
end;
end;
end.
lalu di run kan atau tekan f9 di keyboard...
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
SILAHKAN KOMENTARNYA
tolong komentarnya.....