Scanline Polygon Filling Algorithm
Scanline Polygon Filling Algorithm
Basic algorithm
Assume scan line start from the left and is outside the polygon.
When intersect an edge of polygon, start to color each pixel (because now were inside the
polygon), when intersect another edge, stop coloring
Odd number of edges: inside
Even number of edges: outside
What happens when a scan line intersects an edge endpoint, it intersects two edges.
Two cases:
Case A: edges are monotonically increasing or decreasing
Case B: edges reverse direction at endpoint
In Case A, we should consider this as only ONE edge intersection
In Case B, we should consider this as TWO edge intersections