Patent ID: 6847362

Claim:
A fast line drawing method, comprising the steps of: (a) receiving the coordinates of two end points as (x1,y1) and (x2,y2); (b) assigning the coordinate (X,Y) of a current point as (x1,y1), computing the differences of x and y coordinates of the end points as Δx and Δy, assigning Q as the integer part of Δx over Δy, and assigning the initial sum of error E as −Δx, and two constants K 1 and K 2 as 2Δy and 2*Q*Δy; (c) checking whether the x-coordinate of the current point (X) has reached the x-coordinate of the end point (x 2 ); (d) testing whether the value of E is non-negative; (e) drawing a point at the current point if E is negative, updating the x-coordinate of the current point (X) and E by X+1 and E+K 1 respectively, and returning to step (c); (f) updating the y-coordinate of the current point (Y) and E by (Y+1) and (E−2Δx) respectively if E is non-negative; (g) checking whether the x-coordinate of the last of Q points (X+Q−1) is less than the x-coordinate of the end point (x 2 ); (h) drawing a span of pixels from (X,Y) to (X+Q−1,Y) if the x-coordinate of the last of Q points (X+Q−1) is less than the x-coordinate of the end point (x 2 ); (i) drawing a span of pixels from (X,Y) to (x 2 ,Y) if the x-coordinate of the last of Q points (X+Q−1) is not less than the x-coordinate of the end point (x 2 ); and (j) updating the x-coordinate of the current point (X) and E by X+Q and E+K 2 respectively, and returning to step (c).