Graphics Reference
In-Depth Information
procedure
InitializeData ()
begin
integer
i;
activePolys :=
nil
;
activeEdges :=
nil
;
{ Initialize all buckets to
nil
}
for
i:=YMIN
to
YMAX
do
buckets[i] :=
nil
;
for each
polygon P in the world
do
begin
Create a new polydata record pData for P (active field is set to
false
);
Add pData to buckets[pData.y];
end
end
;
procedure
ProcessActiveEdgeList ()
begin
color
spanColor;
integer
polyCount;
edgedata
E;
polydata
P;
spanLeft := XMIN;
polyCount := 0;
for
E
in
activeEdges
do
begin
spanRight := E.x;
{LA}
case
polyCount
of
0 : spanColor := backgroundColor;
1 : spanColor := ColorOf (OnlyMemberOf (activePolys));
>1 : spanColor := LastVisiblePolygonColor;
end
;
P := PolydataOf (E);
ToggleActive (P);
{ if active field
true
, set to
false
and vice versa }
if
IsActive (P)
then
polyCount := polyCount + 1
else
polyCount := polyCount - 1;
{LB}
Display ([spanLeft,spanRight],spanColor);
spanLeft := spanRight;
end
;
if
spanLeft < XMAX
then
Display ([spanLeft,XMAX],backgroundColor);
end
;
Algorithm 7.8.1.
Continued