Apex › Storage & databases

Bresenham's line algorithm — drawing with integers

How a computer draws a straight line on a grid of pixels (Bresenham, IBM, 1962). The naive way computes y = y0 + slope·(x−x0) and rounds — a floating-point multiply per pixel. Bresenham tracks a single integer error term and decides each step with only additions and comparisons, lighting up the exact same pixels with no multiply, divide, float, or round. Still in every GPU. Click the grid to move the endpoint.

More in Storage & databases