Bézier curves: the smooth curves behind every letter
In every font on your screen, in the pen tool of drawing apps, and in the easing of smooth animations
What problem does it solve?
How does a computer store a perfectly smooth curve with just a few numbers?
The big idea
A Bézier curve is a 'lerp of lerps'. Slide a point a fraction t along each edge between control points, connect those new points, and slide along those too; the last point standing traces the curve as t goes from 0 to 1. The control points act like magnets the curve leans toward, usually without touching them, though it always passes through the two end points. Four points make a cubic curve, and because the maths is just multiply-and-add, the curve scales to any size without going blurry.
How it works, step by step
- 1. Choose control points P₀, P₁, P₂, P₃.
- 2. For a value t between 0 and 1, find the point t of the way along each segment P₀P₁, P₁P₂, P₂P₃.
- 3. Do the same on the two segments joining those three new points, then once more on the last segment.
- 4. The final point is on the curve; sweep t from 0 to 1 to draw it all (de Casteljau's method).
The key formula
- how far along the curve, from 0 (start) to 1 (end)
- the endpoints, which the curve touches
- the 'handles', which pull the curve but usually aren't touched
- weights that always add up to 1, so each curve point is a weighted average of the controls
How fast is it?
A handful of multiplications per point, cheap enough to draw millions of letter outlines a second. TrueType fonts use quadratic (3-point) Béziers; PostScript-style (CFF) fonts use cubic ones.
Try it yourself
- Set both handles equal to the endpoints. What shape do you get?
- Zoom a letter on your screen as far as you can. Why do the edges stay sharp?
Fun fact
Two French car companies discovered the same curves around 1960 to describe car-body shapes: Paul de Casteljau at Citroën, whose work was kept secret, and Pierre Bézier at Renault, who published, so the curves got his name.