
Fourth
By: a guest on Dec 22nd, 2009 | syntax:
C++ | size: 0.49 KB | hits: 1,622 | expires: Never
/*
** Author: Nicholas Forysinski
*/
/*
** drawLine
**
** Draw a line from vertex (x0,y0) to vertex (x1,y1) using
** the midpoint line algorithm (as discussed in class).
*/
void drawLine {
if( dx > dy ) {
x = x0
foreach step until x>=x1 {
draw a pixel
adjust d and y values
}
} else {
y = y0
for each step while y != y1 {
draw a pixel
adjust d and x values
}
}
}