Explain Bresenhams Line Drawing Algorithm?

1 month ago

Bresenhams line drawing algorithm

In Bresenham’s approach the pixel position along a line path are determined by sampling unit X intervals.

Starting from the left end point(X0, Y0)of a given line we step to each successive columns and plot the pixel whose scan line Y-value is closest to the line path.Assuming the Kth step in process, determined that the pixel at (Xk, Yk)decide which pixel to plot in column Xk+1.

The choices are (Xk+1, Yk) and (Xk+1, Yk+1)


Step 1: Input the line endpoints and store the left endpoint in (X0, Y0) Step 2: Load (X0, Y0) in to the frame buffer.

Step 3: Calculate constants   x,   y, 2   y, -2   x, and obtain the decision parameters as

P0 = 2   y –   x

Step 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

Step 5: Repeat step 4 x times

Rajiv Bikram
Oct 20, 2021
More related questions

Questions Bank

View all Questions