Bresenham’s Line Algorithm
1. Input two line endpoints (x1, y1) and (x2, y2)
2. Calculate constants:
Δx=x2 – x1
Δy=y2 – y1
2Δy
2Δy-Δx
3. Assign value to the starting parameter :
k=0
P0=2Δy-Δx
4. Plot the pixel at (x1, y1)
5. For each integer X Co-ordinate, Xk along the line.
if Pk<0, the next point to plot is (xk+1, yk)
Pk+1=Pk+2Δy
else
the next point to plot is (xk+1, yk+1)
Pk+1=Pk+2Δy-2Δx
6. Repeat Step 5 Δx lines.
2. Calculate constants:
Δx=x2 – x1
Δy=y2 – y1
2Δy
2Δy-Δx
3. Assign value to the starting parameter :
k=0
P0=2Δy-Δx
4. Plot the pixel at (x1, y1)
5. For each integer X Co-ordinate, Xk along the line.
if Pk<0, the next point to plot is (xk+1, yk)
Pk+1=Pk+2Δy
else
the next point to plot is (xk+1, yk+1)
Pk+1=Pk+2Δy-2Δx
6. Repeat Step 5 Δx lines.
Recommended Posts:
Computer Graphics
1. Display Devices in Graphics
2. Raster Scan Display
3. Random Scan Display
4. Input Devices
5. Output Devices
6. Types of Printer
7. Pixel and Resolution in Graphics
8. Aspect Ratio
9. Refresh Rate and Interlacing
10. Digital Differential Analyzer (DDA) Algorithm
11. Bresenham’s Line Algorithm
12. Bresenham’s Circle Drawing Algorithm
13. Difference Between DDA and Bresenham’s Line Algorithm
14. MidPoint Circle Drawing Algorithm
15. Anti-Aliasing in Graphics