# 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)

Well, for the first octant you can either step EAST or NORTH-EAST. Depending on the distance to the actual line you choose the appropriate. In many integer implementations, this is done with regard to the sign of D.

• But why doesn't it work for lines with slopes greater than 1 though? Commented Dec 7, 2018 at 23:26
• How would we actually accomplish drawing these lines with slopes greater than 1 persay Commented Dec 7, 2018 at 23:29
• The code only caters for the first octant by design. Well, this is easy to understand if you draw a line in the second octant. Here you will have to mirror the code in y=x, broadly speaking, or in other words step NE and N. This is the sign (dx) and sign (dy) you see in the implementations online. Commented Dec 9, 2018 at 0:26