Graphics Reference
In-Depth Information
{ Global variables }
integer
x, y, lx, rx;
a stack of pixel coordinates (x,y);
procedure
Fill
(integer
seedx, seedy)
begin
x := seedx; y := seedy;
if not
(Inside (x,y))
then
Exit;
Push (x,y);
while
StackNotEmpty ()
do
begin
PopXY ();
if
Inside (x,y)
then
begin
FillRight (); FillLeft ();
{ Fill segment containing pixel }
ScanHi (); ScanLo ();
{ Scan above and below current segment }
end
end
end;
procedure
FillRight ()
begin
integer
tx;
tx := x;
{ Move right setting all pixels of segment as we go }
while
Inside (tx,y) and (tx £ XMAX) do
begin
Set (tx,y); tx := tx + 1;
end;
rx := tx - 1; { Save index of right most pixel in segment }
end;
procedure
FillLeft ()
begin
integer
tx;
tx := x;
{ Move left setting all pixels of segment as we go }
while
Inside (tx,y)
and
(tx ≥ XMIN)
do
begin
Set (tx,y); tx := tx - 1;
end;
lx := tx + 1; { Save index of left most pixel in segment }
end;
Algorithm 2.4.2.
The Smith seed fill algorithm.