Monday 22 February 2016

BRESENHAM’S LINE ALGORITHM

BRESENHAM’S LINE ALGORITHM

Bresenham Line ( X1, Y1, XN, YN):
Description: Here X1 and Y1 denote the starting x – coordinate and y – coordinate of the line
and XN and YN denote the ending x – coordinate and y – coordinate.

1. Set DX = XN – X1 and DY = YN – Y1
2. Set Di = 2DY - DX
3. Set DS = 2DY and DT = 2(DY – DX)
4. Call PutPixel(X1, Y1)
5. Repeat While (X1 < XN)
6. Set X1 = X1 + 1
7. If (Di < 0) Then
8. Set Di = Di + DS
9. Else
10. Set Y1 = Y1 + 1
11. Set Di = Di + DT
[End of If]
12. Call PutPixel(X1, Y1)
[End of While]
13. Exit

This is line ALGORITHM if you got any error please feel to comment.This Very easy to understand and learn. 

0 comments:

Post a Comment