Graphics / Playgrounds / Line rasterisation

Line rasterisation draft

Line rasterisation lets you change the segment endpoints and choose the naïve, DDA, integer Bresenham or floating-endpoint Bresenham method. Use Step, Back, Run and Reset to follow the selected algorithm and inspect the state and operations carried at each pixel.

first octant: x0 < x1, 0 <= m <= 1
0123456789101101234567
m
(y1 - y0)/(x1 - x0) = 0.444
c
y0 - m*x0 = 0.556
  1. x = 1: yi = m*x + c = 0.444*1 + 0.556 = 1; y = round(yi) = 1
  2. x = 2: yi = m*x + c = 0.444*2 + 0.556 = 1.444; y = round(yi) = 1
  3. x = 3: yi = m*x + c = 0.444*3 + 0.556 = 1.889; y = round(yi) = 2
  4. x = 4: yi = m*x + c = 0.444*4 + 0.556 = 2.333; y = round(yi) = 2
  5. x = 5: yi = m*x + c = 0.444*5 + 0.556 = 2.778; y = round(yi) = 3
  6. x = 6: yi = m*x + c = 0.444*6 + 0.556 = 3.222; y = round(yi) = 3
  7. x = 7: yi = m*x + c = 0.444*7 + 0.556 = 3.667; y = round(yi) = 4
  8. x = 8: yi = m*x + c = 0.444*8 + 0.556 = 4.111; y = round(yi) = 4
  9. x = 9: yi = m*x + c = 0.444*9 + 0.556 = 4.556; y = round(yi) = 5
  10. x = 10: yi = m*x + c = 0.444*10 + 0.556 = 5; y = round(yi) = 5
0 / 10

Reference