Bres line

procedure bres_line(x1,y1,x2,y2: integer)

var

dx,dy,x,y,p.const1,const2: integer;

begin

dx:=x2-x1;

dy:=y2-y1;

p:=2*dy-dx;

const1:=2*dy;

const2:=2*(dy-dx);

x:=x1;

y:=y1;

putpixel(x,y,color);

while (x<x2) do

begin

x:=x+1;

if(p>0) then p:=p+const1;

else

begin

y:=y+1;

p:=p+const2;

end;

putpixel(x,y,color);

end;

end;

Bạn đang đọc truyện trên: AzTruyen.Top

Tags: #hoa