Graphics Reference
In-Depth Information
while
x £ XMAX
do
if
wasIn
then
begin
if
Inside (x,y)
then
Set (x,y) { was inside and still inside }
else
begin
{ was inside but not anymore, i.e., we
just passed the right edge of a span }
Stack (dadLx,dadRx,lx,x-1,y,dir);
wasIn :=
false;
end
end
else
begin
if
x > rx
then Goto 2;
if
Inside (x,y)
then
begin
{ we weren't inside but are now, i.e.,
we just found the left edge of a new span }
Set (x,y);
wasIn :=
true;
lx := x;
end
x := x + 1;
end;
2
:
if
wasIn
then
{ we just hit the edge of the viewport while in a span }
Stack (dadLx,dadRx,lx,x-1,y,dir);
end
end;
boolean function
StackNotEmpty ()
{ Returns
true
if shadowStack is empty and
false
otherwise }
procedure
Push (
integer
myl, myr, dadl, dadr, y;
direction
dir)
{ Pushes record onto shadowStack }
procedure
Pop ()
{ Pops top of shadowStack into local variables lx, rx, dadLx, dadRx, y, dir }
procedure
Stack (
integer
dadLx, dadRx, lx, rx, y;
direction
dir)
{ Pushes an extra shadow onto shadowStack, given a newly discovered span
and its parent. This is where the three types of shadows are differentiated. }
begin
Algorithm 2.4.3.
Continued