Algoritma Simetri 4X, Algoritma Lingkaran Bresenham, & Output Primitif


Algoritma Simetri 4X, Algoritma Lingkaran Bresenham, & Output Primitif

Sahabat kreatif Indonesia,
kali ini admin akan membahas sedikit tentang bagaimana cara mengimpementasikan Algoritma Simetri 4X, Algoritma Lingkaran Bresenham, & Output Primitif kedalam program dengan menggunakan delphi7.
Okay cekidot ya berikut listing programnya,


procedure TForm1.Button1Click(Sender: TObject);
var d,c,x,y,theta,theft:real;
    xc,yc,r,r2:integer;
begin
     xc:=170;
     yc:=200;
     r:=35;
     r2:=90;
     theft:=0.0;
     d:=2*PI;
     theta:=d/4;
     c:=1/(r);

     while (theft<theta) do
     begin
     x:=r*cos(theft)  ;
     y:= r2*sin(theft);

     canvas.Pixels[trunc(xc+x),trunc(yc+y)]:=clblue;
     canvas.Pixels[trunc(xc+x),trunc(yc-y)]:=clblue;
     canvas.Pixels[trunc(xc-x),trunc(yc+y)]:=clblue;
     canvas.Pixels[trunc(xc-x),trunc(yc-y)]:=clblue;
     canvas.Pixels[trunc(xc+y),trunc(yc+x)]:=clblue;
     canvas.Pixels[trunc(xc+y),trunc(yc-x)]:=clblue;
     canvas.Pixels[trunc(xc-y),trunc(yc+x)]:=clblue;
     canvas.Pixels[trunc(xc-y),trunc(yc-x)]:=clblue;
     theft:=theft+c;
end;


end;

procedure TForm1.Button2Click(Sender: TObject);
  var x,y,p,xc,yc,r:integer;
begin
  xc:=       170;
  yc:=200;
  r:=35;
  x:=0;
  y:=r;
  p:=(3-(2*r));

  while (x<y)do
  begin
  canvas.Pixels[xc+x,yc+y]:=clred;
  canvas.Pixels[xc+x,yc-y]:=clred;
  canvas.Pixels[xc-x,yc+y]:=clred;
  canvas.Pixels[xc-x,yc-y]:=clred;
  canvas.Pixels[xc+y,yc+x]:=clred;
  canvas.Pixels[xc+y,yc-x]:=clred;
  canvas.Pixels[xc-y,yc+x]:=clred;
  canvas.Pixels[xc-y,yc-x]:=clred;

   if (p<0) then p:=(p+(4*x)+6)
   else begin
   p:=(p+(4*(x-y))+10);
   y:=y-1;
   end;
   x:=x+1;
   end;

end;

procedure TForm1.Button3Click(Sender: TObject);
var c,x,y,theta,theta_b:real;
r,xc,yc:integer;

begin
r:=200;xc:=350;yc:=205;
c:=1/(r);
theta:=0.0;
theta_b:=2*PI;
  while(theta<theta_b)do
  begin
  x:=xc+r*cos(theta);
  y:=yc-r*sin(theta);
  canvas.pixels[trunc(x),trunc(y)]:=clblack;
  theta:=theta+c;

end;
end;
end.


Nah, ini dia output programnya ..

Mudah bukan cara input dan output nya..
Jangan lupa hastag link asli nya  Http://Blogbriyann.blogspot.com

Poskan Komentar