



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




− Intersect scanline with polygon edges − Fill between pairs of intersections − Basic algorithm: For y = ymin to ymax
However, we need to handle some special cases and improve the performance Special handling: a) Make sure we only fill the interior pixels Define interior: For a given pair of intersectin points (Xi, Y), (Xj, Y) −> Fill ceiling(Xi) to floor(Xj) important when we have polygons adjacent to each other b) Intersection has an integer X coordinate −> if Xi is integer, we define it to be interior −> if Xj is integer, we define it to be exterior (so don’t fill)
Special handling (cont’d) c) Intersection is an edge end point (cont’d) However, in this case we don’t want to count p1 twice (p0,p1,p1,p2,p3), otherwise we will fill pixels between p1 and p2, which is wrong p0 p1 p2 p e e
Special handling (cont’d) c) Intersection is an edge end point (cont’d) Rule: If the intersection is the ymin of the edge’s endpoint, count it. Otherwise, don’t. ymin ymax p0 p1 p e1 e scanline Yes, count p1 for both e1 and e p0 p1 p2 p e e No, don’t count p1 for the edge e