Scan Converting Polygons by Hand:
Sample Point Algorithm
The algorithm demonstrated here assigns a pixel to a polygon if the lower
left corner of the pixel is inside the polygon. This corner is considered
the sample point. Great care is taken at sample points which lie on an
edge or vertex of a polygon to ensure that no two non-overlapping polygons
share a pixel.
For this demo, polygons can be drawn one vertex at a time, the most
recent can be deleted, or all polygons can be deleted, but no other editing
operations are supported. With snapping mode on (the default), we can draw
polygons with shared vertices and observe that (hopefully) none of the
pixels overlap.
Viewing commands:
-
-> - Use arrow keys to navigate
-
c - clear polygons
-
d - delete the current polygon
-
e - toggle display of edges
-
g - toggle display of grid
-
h - print this help message
-
n - next polygon
-
r - repaint screen
-
s - toggle snapping of vertices to grid
-
v - toggle display of vertices
-
x - zoom out
-
z - zoom in
Clicking the mouse in the applet window adds a vertex to the current polygon.
The pseudo-code
for this algorithm is also available.