XIAOLIN WU'S LINE Bresenham's line, with the jaggies filed off
Bresenham’s line (dart 003) is fast but jagged — each pixel is fully on or off, so a shallow diagonal stair-steps. Wu’s line keeps Bresenham’s speed but colours two pixels per step, their brightness set by how much of each the ideal line covers — and the stairs melt into a smooth stroke.
THE TECHNIQUE two pixels per step, weighted by coverage
Step along the major axis. At each step the true line falls between two pixel rows; light both, giving the nearer one most of the brightness and the farther one the rest (their coverages sum to 1). The eye blends them into a clean edge. Below: the same line drawn aliased (Bresenham) and antialiased (Wu). live demo
HISTORY & CREDIT not the first antialiased line — the fast one
“Wu invented antialiased lines” — smooth lines existed first in 1991 a decade earlier; Wu made them cheap. cited
1965 / 1962 · Bresenham’s integer line (dart 003) draws fast but aliased — every pixel fully on or off. 1981 · Gupta & Sproull draw antialiased lines by looking up straddling-pixel intensities in a precomputed filtered-distance table — smooth, but with a table. 1991 · Xiaolin Wu (“An Efficient Antialiasing Technique,” SIGGRAPH) re-derives the coverage as a simple incremental computation — an error accumulator like Bresenham’s, plus a symmetry trick that draws from both ends — so antialiasing costs almost nothing extra. the paper · is titled about antialiasing generally and covers circles too; “Wu’s line” is a later community name.
The jagged and the smooth line are the same walk down the same slope — one rounds coverage to 0/1, the other keeps the fraction. Wu 1991, after Gupta-Sproull
RECOMMEND FOR I-13 Bresenham plus a fraction
Wu’s line is Bresenham’s walk (dart 003, which runs) but keeping the fractional coverage instead of rounding it. The popularized f64 form:
// per step: intensity of pixel = 1 - frac(y), neighbour = frac(y)
// then advance y by the slope. plain f64 add/floor/frac.
Recommend:nothing new — the coverage is 1 − frac(y) and its complement, advanced by the slope each step. Add, floor, fraction — all f64 the compiler has. The output grid (the pixels) is the array; the intensities are f64. (Historically Wu’s own 1991 method is integer/fixed-point — his abstract boasts even less integer arithmetic than Bresenham; the f64 coverage form here is the later popularized pseudocode, the corpus’s reimplementation choice.) Note: a neat pair with dart 003 — same slope, same walk; Bresenham rounds the coverage to 0/1 (jagged), Wu keeps the fraction (smooth) — both integer at heart, the f64 rendering here the corpus’s. The campaign has now run both faces of the oldest graphics primitive.