The Fourier Drawing Machine
Feed in any closed curve — a butterfly, a heart, your own signature — and the discrete Fourier transform will hand you back the minimum vocabulary of rotating circles needed to reproduce it. Each harmonic is one circle spinning at an integer frequency; chain them tip-to-tail and the last pen draws the curve. Truncate the chain and you see what the first k harmonics alone can say about the shape. Ptolemy was nearly right.
The idea
A closed curve in the plane can be treated as a complex-valued function
z(t) = x(t) + i y(t) on t ∈ [0, 2π). If it's square-integrable (every
drawable curve is), it admits a Fourier series
z(t) = Σ k∈ℤ ck e i k t, ck = (1/2π) ∫ z(t) e−i k t dt
Each term ck eikt is a vector of length |ck|
spinning at k revolutions per cycle with initial phase arg ck.
Summing the vectors tip-to-tail is exactly what you see on the canvas.
What actually happens here
The curve is sampled at N = 512 points, equally spaced along its arc length (this matters — the
DFT assumes uniform parameterisation, and most parametric curves don't oblige). An O(N²) DFT
gives c0 … cN−1; frequencies above N/2 are
reinterpreted as negative frequencies. The coefficients are sorted by magnitude so the largest
circles render first and the tiny high-frequency harmonics sit at the tip, where they matter.
Truncation and Parseval
Pull the terms slider left and you are deliberately throwing information away. The
RMS error readout is Parseval's identity put to work: the ℓ² norm of the discarded
coefficients is exactly the root-mean-square reconstruction error. A few dozen harmonics will
capture the gross shape; the last few hundred live almost entirely in the corners and cusps.
Draw your own
Hit Draw, sketch a closed loop on the canvas in one stroke, and release. Your
input is resampled and transformed on the spot. Messy input is fine — the truncation slider
will smooth it for you, which is essentially a low-pass filter in the frequency domain.