Remark for the Bresenham Line Generation Algorithm
Remark: The algorithm will be properly the same if we suppose | m | < 1
(a) Input two line ending points and store left end point in (x_{0}, y_{0}) (b) Load (x_{0}, y_{0}) on frame buffer that is, plot the first point.
(c) Determine Δx, Δy, 2Δy, 2Δy - 2Δx and acquire the beginning value of decision parameter as p_{0} = 2Δy - Δx
(d) At each x_{k} along the line, beginning at k = 0, perform subsequent test:
If p_{k} < 0, the subsequent plot is (x_{k + 1}, y_{k}) and p_{k + 1} = p_{k} + 2Δy else subsequent plot is (x_{k + 1} , y_{k + 1}) and p_{k + 1 }= p_{k} + 2(Δy - Δx)
(e) Repeat step (D) Δx times.
Bresenham Line Generation Algorithm (| m | < 1)
Δ x ← x1 - x_{0}
Δ y ← y1 - y_{0}
p_{0} ← 2Δy - Δx
while (x_{0} < = x_{1}) do
{puton (x_{0}, y_{0})
if (p_{i} > 0) then
{x_{0} ← x_{0 }+ 1;
y_{0} ← y_{0 }+ 1;
p_{i + 1} ← p_{i }+ 2 (Δy - Δx);
}
if (p_{i} < 0) then
{x_{0} ← x_{0 }+ 1
y_{0} ← _{y}0
p_{i + 1} ← p_{i }+ 2 Δy
}
}