Scanline Fills
Eric Leive, Xiang Lan Zhuo
Functions implemented
- PolyFill()
- CircleFill()
- EllipseFill()
- Polyline()
- TransCircleFill()
Tasks
Eric implemented the CircleFill, EllipseFill and TransCircleFill functions. Xiang Lan implemented the PolyFill and Polyline functions.
PolyFill Algorithm
We discovered a bug with our PlotPixel function that rotates the origin of a ppm image from upper-left corner to lower-left corner. The original transformation given x and y coordinate of a point is:
image[(height-x) * width + y]
where height and width is image's height and width, (x,y) is the pixel to plot
This transformation actually ships the x component of a point one pixel to the right. To correct this error, here is the new transformation for our PlotPixel function:
image[(height-x-1) * width + y].
Correct Area Filled?
To see if the PolyFill algorithm acutally fills the correct area, we first made a square with coordinates (0,0), (100,0), (100,100), (0,100). If the algorithm is correct, the number of pixel filled should be 101 * 101 = 10201 pixels. By running the image in a for loop and count the number of pixels filled, the result returned 10100 pixels. Therefore, the algorithm is missing 101 pixels, which amounts to one scanline on the right side of the square.
The problem was solved by changing the test condition in fillScan that looks for the x intersect of edge 1 and edge 2. Instead of having the incremental var i test to see if it's less than edge 2's x intersect, change the condition to less than or equal to edge 2's x inersect.
Polygon Fill Efficiency
The PolyFill() algorithm can fill around 66,500 6-sided polygons within an area of 900 pixels in one second.
Circle Fill Efficiency
The CircleFill() algorithm can fill 61,219 circles with a radius of 15 pixels in one second.
Circle Transparency Fill
The transparency function is simply a rewrite of the Plot Pixel function. A real number (from 0 to 1) is passed into the function which determines the ratio of the foreground color to the background color, and then plots that color value instead of just the foreground color.
Images
Polyline
|
PolyFill
|
Circle Transparency Fill
|
Ellipse Fill
|
XL's box on table
|