algorithmbresenhamline-drawing

Bresenham's algorithm next pixel?


In line drawing, bresenham's algorithm was explicitly derived for lines with slopes between 0 and 1 in the first octant from point P1 to point P2, where the x value of P1 is less than that for P2.

In the incremental version of this algorithm, once a pixel is drawn, we need to choose the next pixel to draw.

What are the choices? How do we go about choosing which pixel to draw next? (assuming a line width of 1 pixel)


Solution

  • In the first octant, the only choices are right or up-right, and you take the closest to the exact line. The error is computed incrementally.