sekarang saya akan membahas mengenai program grafika komputer tentang algoritma treeleaf........(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:=154;
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:=(c*cos(theta))+cos(thetf)/(c*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.
kemudian coba di cek keseluruhannya....diharapkan sama 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:=154;
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:=(c*cos(theta))+cos(thetf)/(c*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.
sekian dan trima kasih.....
Tidak ada komentar:
SILAHKAN KOMENTARNYA
tolong komentarnya.....