Sections:
Our scanline fill algorithm implements the standard scanline fill algorithm (from class notes). We first build a list of the non-horizonatal edges in the polygon, storing the start and end y value for each edge, as well as its initial x value, and the change in x with respect to y. Starting at the minimum y value, we check to see which edges exist at that y value, and build a list of those "active" edges. Then by sorting the list of active edges, and drawing horizontal lines between the x values of pairs of edges, we are able to fill all the correct pixels on that scan line. We then update the list of active edges, by adding the dx value to the initial x value (since we are about to scan on the next line, and have therefore increased y by one) and checking to see if there are any new edges that should be active and whether any of the active edges are not longer active. We then repeat for every value of y that intersects any of the edges in the polygon.
![]() Required image one: A scanline filled polygon. |
![]() Another scanline filled polygon. |
![]() A scanline gradient filled polygon! |

Required image 2: an awesome 3D car! (By Will) Updated since the last lab to use our new filling techniques and added road detail with pattern filling. |
Required image 2: totally cool gradient train! (By Andrew) |
A colorful bull's eye (Andrew's Portfolio 7) |
Still life with Stewie (Will's Portfolio 7) |
AC stands for...? (Andrew's Portfolio 8) |
Faded Circles (Will's Portfolio 8) |
newPixelX = (positionX - patternOriginX) % patternWidth
newPixelY = (positionY - patternOriginY) % patternHeight
Here are the new methods:
A filled polygon with a pattern. |
The same polygon shifted. Notice how the pattern origin moves with the polygon. |
Flood Fill:
We actually added flood filling in the last lab.
Gradients: The Next Generation:
In the last lab we added limited gradient filling with flood fill. In this lab we extend gradient filling in the following ways:
A pretty filled rect with a diagonal gradient and interesting color scheme. |
And a circle. |
Another rectangle. |
We can gradient lines too! |