{,        .
  ,    uGraph, , 
procedure uGraph_LineX(X1,X2,Y:OptInt16;Color:OptWord);{  }
procedure uGraph_LineY(X,Y1,Y2:OptInt16;Color:OptWord);{  }
procedure uGraph_LineD(X1,Y1,X2,Y2:OptInt16;Color:OptWord);{  }
procedure uGraph_Line(X1,Y1,X2,Y2:OptInt16;Color:OptWord);{  }
 ,    ,   .}


const SizeScreenX=639;SizeScreenY=479;{ 640x480 16 color 1 page }

procedure uGraph_LineX(X1,X2,Y:OptInt16;Color:OptWord);{  }
var cX0,cX1,cX2:OptWord;
begin
If (Y>=0) and (Y<=SizeScreenY) then begin
if (X1<0) then X1:=0 else if X1>SizeScreenX then X1:=SizeScreenX;
if (X2<0) then X2:=0 else if X2>SizeScreenX then X2:=SizeScreenX;
if X1>X2 then begin cX1:=X2;cX2:=X1 end else cX1:=X1;cX2:=X2;

for cX0:=cX1 to cX2 do uGraph_PutPixel(cX0,Y,Color);

end;end;

procedure uGraph_LineY(X,Y1,Y2:OptInt16;Color:OptWord);{  }
var cY0,cY1,cY2:OptWord;
begin
If (X>=0) and (X<=SizeScreenX) then begin
if (Y1<0) then Y1:=0 else if Y1>SizeScreenY then Y1:=SizeScreenY;
if (Y2<0) then Y2:=0 else if Y2>SizeScreenY then Y2:=SizeScreenY;
if Y1>Y2 then begin cY1:=Y2;cY2:=Y1 end else cY1:=Y1;cY2:=Y2;

for cY0:=cY1 to cY2 do uGraph_PutPixel(X,cY0,Color);
end;end;



procedure uGraph_LineD(X1,Y1,X2,Y2:OptInt16;Color:OptWord);{  }
var dx, dy, sx, sy, err, e2:OptInt16;

begin  pRCP:=0;  dx := abs(x2 - x1);   dy := abs(y2 - y1);
if X1 < X2 then sx := 1 else sx := -1;   if Y1 < Y2 then sy := 1 else sy := -1;
err := dx - dy;
while (x1 <> x2) or (y1 <> y2) do
Begin
{uGraph_PutPixel(x1, y1, color);}
If (X1>=0) and (X1<=SizeScreenX) and (Y1>=0) and (Y1<=SizeScreenY) then begin
  uGraph_PutPixel(X1,Y1,Color);
end;

e2 := 2 * err;
if e2 > -dy then begin err := err - dy; x1 := x1 + sx; end;
if e2 < dx then begin err := err + dx; y1 := y1 + sy; end;
end;
end;


procedure uGraph_Line(X1,Y1,X2,Y2:OptInt16;Color:OptWord);{  }
begin
If Y1=Y2 then uGraph_LineX(X1,X2,Y1,Color) else{  }
If X1=X2 then uGraph_LineY(X1,Y1,Y2,Color) else {  }
uGraph_LineD(X1,Y1,X2,Y2,Color);{  }
end;







