Rabu, 10 Oktober 2012
ALGORITMA TREELEAF 3
menggunakan delphi7,,,,,silahkan dicoba
procedure TForm1.Button1Click(Sender: TObject);
var r,d,e,c,x,y,z,theta,thetf: real;
a,xc,yc:integer;
begin
a:=184;
xc:=300;
yc:=300;
thetf:=10.10;
d:=30*PI;
e:=6*sin(45*thetf);
theta:=a+d+e;
c:=1/a;
while (thetf<theta) do
begin
r:=a+d/cos(15*thetf);
x:=d+r*cos(thetf);
y:=a-r*sin(thetf);
canvas.pixels[trunc(xc+x),trunc(yc+y)]:=clred;
canvas.pixels[trunc(xc-x),trunc(yc+y)]:=clred;
canvas.pixels[trunc(xc+x),trunc(yc-y)]:=clred;
canvas.pixels[trunc(xc-x),trunc(yc-y)]:=clred;
thetf:=thetf+c;
end;
end;
end.
disamakan yang di bawah ini keseluruhannya....
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:=184;
xc:=300;
yc:=300;
thetf:=10.10;
d:=30*PI;
e:=6*sin(45*thetf);
theta:=a+d+e;
c:=1/a;
while (thetf<theta) do
begin
r:=a+d/cos(15*thetf);
x:=d+r*cos(thetf);
y:=a-r*sin(thetf);
canvas.pixels[trunc(xc+x),trunc(yc+y)]:=clred;
canvas.pixels[trunc(xc-x),trunc(yc+y)]:=clred;
canvas.pixels[trunc(xc+x),trunc(yc-y)]:=clred;
canvas.pixels[trunc(xc-x),trunc(yc-y)]:=clred;
thetf:=thetf+c;
end;
end;
end.
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
SILAHKAN KOMENTARNYA
tolong komentarnya.....