How it works
In 1876 Alfred Kempe showed that any curve you can write down as a polynomial can be drawn by a machine of rigid bars and pins, one whose pen can move only along that curve. (His argument had a gap that wasn't closed until 2002.) The machine is built from parts that add angles, multiply them and copy them from place to place. It works, but even modest curves need a great many bars.
This page looks for small machines instead. It can't promise an exact trace, but it often gets close with a dozen bars or fewer, and it always tells you how close.
Twenty million random machines
Every machine is built the same way: some fixed pivots; a motor crank; sometimes a second or third crank, belted to the motor so it turns a whole number of times per turn, in either direction; then joints, each tied by two bars to parts already placed. Built that way a machine has exactly one way to move, so the motor's angle fixes every joint, and its motion can be computed exactly. I generated 20 million of them at random on a laptop GPU, threw out any that jam before a full turn or whose bars ever meet at too shallow an angle to push through, and kept every joint whose path stays compact next to its machine: 34.7 million candidate pens.
Choosing the machines on this page
That many machines won't fit in a web page, so the page carries 309,307 of them, chosen for how people actually draw. For each of about 150,000 one-stroke doodles from Google's Quick, Draw! dataset, I checked the 600 machines out of all 34.7 million with the closest fingerprints (more on those below), lined each one up with the doodle exactly, and kept the best three, plus 20,000 at random for variety. Then I ran this page's own search and tuning on 65,124 training doodles and shapes, and kept the 49,319 tuned machines that got within 15%. A new drawing usually starts from a machine that has already been bent into a similar shape.
Finding and tuning yours
When you lift the pen, the page compares a fingerprint of your drawing with every machine's. The fingerprint is the sizes of the drawing's first ten Fourier components, which don't change when a shape is moved, turned, scaled, mirrored, or started from a different point. It takes the 800 closest machines and lines each one up with your drawing exactly: sliding its start point, then turning, scaling and mirroring it for the best fit.
The machines whose paths start closest aren't always the ones that tune best, so a small neural network, trained on how 3.1 million doodle-and-machine pairs actually tuned, predicts where each will end up. The page tunes the most promising 40 together, then the best 12 for longer, then the best 3, adjusting every bar length, pivot and crank with Levenberg–Marquardt. You watch the leader as it improves. Tuning keeps the machine drivable, so no joint may lock or bend too flat, and keeps it compact.
How close it gets
The error is the root-mean-square distance between the pen's path and your drawing after the best alignment, as a fraction of your drawing's root-mean-square radius. Below about 3% the two lines are hard to tell apart; around 10% the machine draws a recognisable cousin of your shape.
| Median error | Within 5% | |
|---|---|---|
| Closest machine in the library, untuned | 9.5% | 21% |
| Tuned, from a library chosen for doodles | 6.9% | 38% |
| Adding 49,319 machines tuned to training doodles | 5.7% | 45% |
| Adding the tuning predictor | 5.2% | 49% |
| Tuning for longer, as this page does at “Closer fit” | 5.0% | 50% |
| The page's default, one notch towards fewer bars | 5.5% | 47% |
At “Closer fit” the machines average 12 bars and take about a second on a laptop; the default averages 9. Moons, circles, triangles and fish usually land within 2–3%. The hardest doodles are spirals: snails, lollipops and tornadoes come out between 30% and 50%.
What it can't do
Sharp corners, tight spirals and long wiggly outlines are hard for small machines; the readout always shows the measured error rather than a claim. Open strokes are traced there and back, so a line becomes a very thin loop.
Credits
A. B. Kempe, On a general method of describing plane curves of the nth degree by linkwork (1876). The search-then-tune approach follows LInK (Nobari et al., 2024), which searches a large database of linkages and then optimises the best matches. Doodles from Google's Quick, Draw! dataset (CC BY 4.0). Colours from Braun's palette, via Hue Atlas and the DR01 set.