Graphics Reference
In-Depth Information
procedure
ScanHi ()
{ Scan the pixels between lx and rx in the scan line above the current one.
Stack the left most of these for any segment of our region that we find.
We do not set any pixels in this pass. }
begin
integer
tx;
if
y + 1 > YMAX
then
Exit;
tx := lx;
while
tx £ rx
do
begin
{ Scan past any pixels not in region }
while not
(Inside (tx,y + 1))
and
(tx £ rx)
do
tx := tx + 1;
if
tx £ rx
then
begin
Push (tx,y + 1);
{ We just saved the first point of a segment in region.
Now scan past the rest of the pixels in this segment. }
while
Inside (tx,y + 1)
and
(tx £ rx)
do
tx := tx + 1;
end;
end
end;
procedure
ScanLo ()
{ Scan the pixels between lx and rx in the scan line below the current one.
Stack the left most of these for any segment of our region that we find.
We do not set any pixels in this pass. }
begin
integer
tx;
if
y - 1 < YMIN
then
Exit;
tx := lx;
while
tx £ rx
do
begin
{ Scan past any pixels not in region }
while not
(Inside (tx,y - 1))
and
(tx £ rx)
do
tx := tx + 1;
if
tx £ rx
then
begin
Push (tx,y - 1);
{ We just saved the first point of a segment in region.
Now scan past the rest of the pixels in this segment. }
while
Inside (tx,y - 1)
and
(tx £ rx)
do
tx := tx + 1;
end;
end
end;
Algorithm 2.4.2.
Continued