ALGORITMA PEMBENTUK PISCES

Posted: March 1, 2011 in Pascal

uses graph,crt;
procedure init();
var gd, gm : integer;
begin
gm:=detect; gd:=0;
InitGraph(gd,gm,”);
if GraphResult <> grOk then
begin
Writeln(‘Graph driver ‘,gd,’ graph mode ‘,gm,’ not supported’);
Halt(1);
end;
end;
procedure destroy();
begin
clrscr;
closegraph;
end;
procedure drawLine(xstart,ystart,xend,yend,c:integer);
var
step,k:integer;
dx,dy:real;
x_inc,y_inc,x,y:real;
begin
if(xstart <> xend) or (ystart <> yend) then
begin
dx:=xend-xstart;
dy:=yend-ystart;
x:=xstart;
y:=ystart;
if abs(dx) > abs(dy) then
step:=round(abs(dx))
else
step:=round(abs(dy));
x_inc:=dx/step;
y_inc:=dy/step;
putPixel(round(x),round(y),c);
for k:=1 to step do
begin
x:=x+x_inc;
y:=y+y_inc;
putPixel(round(x),round(y),c);
end;
end;
end;
begin
init;
drawLine(100,50,90,60,white);
drawLine(90,60,103,75,white);
drawLine(103,75,100,50,white);
drawLine(103,75,80,115,white);
drawLine(80,115,75,125,white);
drawLine(75,125,55,150,white);
drawLine(55,150,45,165,white);
drawLine(45,165,70,160,white);
drawLine(70,160,80,155,white);
drawLine(80,155,95,150,white);
drawLine(95,150,100,148,white);
drawLine(100,148,120,150,white);
drawLine(120,150,200,145,white);
drawLine(200,145,220,155,white);
drawLine(220,155,225,170,white);
drawLine(225,170,240,169,white);
drawLine(240,169,250,160,white);
drawLine(250,160,245,155,white);
drawLine(245,155,240,150,white);
drawLine(240,150,220,155,white);
readkey;
destroy;
end.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s