Bresenham's Line Algorithm

An accurate and efficient raster line-generating algorithm, developed by Bresenham, scan converts lines using only incrementa1 integer calculations that can be further adapted to display circles and other curves.

  1. Input the two line endpoints and store the left endpoint in (x0,y0)

  2. Load (x0,y0) into the frame buffer; i.e, plot the first point.

  3. Calculate constants Δx, Δy, 2Δy, and 2Δy - 2Δx, and obtain the starting value for the decision parameter as
    p0 = 2Δy - ΔX

  4. At each xk along the line, starting at k = 0, perform the following test:

    If pk < 0, the next point to plot is (xk + 1 , yk and

    pk + 1= pk + 2Δy

    Otherwise, the next point to plot is (xk + 1 , yk + 1) and

    pk + 1= pk + 2Δy - 2Δx

  5. Repeat step 4 Δx times