ALGORITMA PEMBENTUK PISCES 2

Posted: March 6, 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 drawBressLine(xa,ya,xb,yb,c:integer);
var dx,dy,x,y,xEnd,p,c1,c2:integer;
begin
dx:= (xb-xa);
dy:= (yb-ya);
p:=2*dy-dx;
c1 := 2*dy;
c2 := 2*(dy-dx);
if xa > xb then
begin
x:=xb;
y:=yb;
xEnd:=xa;
end
else
begin
x:=xa;
y:=ya;
xEnd:=xb;
end;
putPixel(x,round(y),c);
while x < xEnd do
begin
inc(x);
if p < 0 then
p:=p+c1
else
begin
inc(y);
p:=p+c2;
end;
putPixel(x,round(y),c);
end;
end;
begin
init;
drawBressLine(100,50,100,50,white);
drawBressLine(90,60,90,60,white);
drawBressLine(103,75,103,75,white);
drawBressLine(80,115,80,115,white);
drawBressLine(75,125,75,125,white);
drawBressLine(55,150,55,150,white);
drawBressLine(45,165,45,165,white);
drawBressLine(70,160,70,160,white);
drawBressLine(80,155,80,155,white);
drawBressLine(95,150,95,150,white);
drawBressLine(100,148,100,148,white);
drawBressLine(120,150,120,150,white);
drawBressLine(200,145,200,145,white);
drawBressLine(220,155,220,155,white);
drawBressLine(225,170,225,110,white);
drawBressLine(240,169,240,169,white);
drawBressLine(250,160,250,160,white);
drawBressLine(245,155,245,155,white);
drawBressLine(240,150,240,150,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