Graphics Reference
In-Depth Information
begin
{ Clip against bottom bdry }
x := x0 + (x1 - x0)*(ymin - y0)/(y1 - y0);
y := ymin;
end
else if
(TOPBDRY
and
c) π 0
then
begin
{ Clip against top bdry }
x := x0 + (x1 - x0)*(ymax - y0)/(y1 - y0);
y := ymax;
end
;
{ Next update the clipped endpoint and its code }
if
c = c0
then
begin
x0 := x; y0 := y;
c0 := RegionCode (x0,y0);
end
else
begin
x1 := x; y1 := y;
c1 := RegionCode (x1,y1);
end
end
; { while }
return
(
true
);
end
;
byte function
RegionCode (
real
x,y);
{ Return the 4-bit code for the point (x,y) }
begin
byte
c;
c := 0;
if
x < xmin
then
c := c + LEFTBDRY
else if
x > xmax
then
c := c + RIGHTBDRY;
if
y < ymin
then
c := c + BOTTOMBDRY
else if
y > ymax
then
c := c + TOPBDRY;
return
(c);
end
;
{ RegionCode }
Algorithm 3.2.1.1.
Continued