Kolton Ndoj

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. 1. Choose control points P₀, P₁, P₂, P₃.
  2. 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. 3. Do the same on the two segments joining those three new points, then once more on the last segment.
  4. 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

B(t)=(1−t)3P0+3(1−t)2t P1+3(1−t)t2P2+t3P3B(t)=(1-t)^3P_0+3(1-t)^2t\,P_1+3(1-t)t^2P_2+t^3P_3
tt
how far along the curve, from 0 (start) to 1 (end)
P0,P3P_0, P_3
the endpoints, which the curve touches
P1,P2P_1, P_2
the 'handles', which pull the curve but usually aren't touched
(1−t)3, 3(1−t)2t,…(1-t)^3,\,3(1-t)^2t,\dots
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.

Graph for Bézier curves: the smooth curves behind every letter 011.5-0.5
One coordinate of a cubic Bézier from 0 to 1: the handles bend it without the curve having to touch them. With handles 0.1 and 1 you get a classic 'ease-in-out' animation curve. (drawn with the default slider values — move the sliders live)

Try it yourself

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.

Related

Open it in the Math Lab →

Games · Intermediate