Draw a line by clicking and dragging on the pixel grid shown with the left mouse
button. An ideal line is displayed until the left button is released. Upon release
a discrete approximation of the line is drawn on the display grid using the
lineSimple() method described in the previous slide. An ideal line is then overlaid
for comparison.
This algorithm works well when the desired line's slope is less than 1, but
the lines become more and more discontinuous as the slope increases beyond one.
Since this algorithm iterates over values of x between x0 and x1 there is a
pixel drawn in each column. When the slope is greater than one then often more
than one pixel must be drawn in each column for the line to appear continuous.
The progression of line drawing algorithms that we will cover is basically a
case study in optimization techniques; at least that's how they will be treated
here. The optimization methodology that we will cover is very general and can
be applied to a wide range of algorithms.