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.
Input the two line endpoints and store the left endpoint in (x0,y0)
Load (x0,y0) into the frame buffer; i.e, plot the first point.
Calculate constants Δx, Δy, 2Δy, and 2Δy - 2Δx, and obtain the starting value for the decision parameter as
p0 = 2Δy - ΔXAt 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
Repeat step 4 Δx times