The Beautiful Maths of the Spirograph
How a circle rolling inside a circle turns two numbers into endless intricate patterns.
A toy built on a theorem
The Spirograph was a hit children's toy of the 1960s: a set of plastic gears you rolled inside toothed rings, a pen poked through one of many little holes, tracing loops that somehow always came out beautiful. What most children never realised is that it is a physical demonstration of a genuine piece of mathematics — a family of curves called roulettes, traced by one shape rolling along another. The digitalSpirographdoes the same thing with sliders, and lets you see the maths directly.
A circle rolling inside a circle
The specific curve a classic spirograph draws is a hypotrochoid. Picture a small circle rolling around the inside of a large fixed ring, without slipping. Now attach a pen to the small circle — not at its centre, but somewhere off to one side. As the small circle rolls, the pen traces a path that loops in and out, and because the small circle spins as it goes around, those loops rotate to fill the whole ring with a symmetric pattern. (If the small circle rolls around the outside instead, you get a close cousin called an epitrochoid.)
Three numbers control everything: R, the radius of the big ring; r, the radius of the rolling circle; and d, how far the pen sits from the rolling circle's centre. Those are exactly the three sliders in the tool.
The equation behind the beauty
Remarkably, the whole intricate pattern comes from one pair of equations. As the parameter t sweeps around, the pen's position is:
x = (R − r)·cos(t) + d·cos(((R − r)/r)·t)
y = (R − r)·sin(t) − d·sin(((R − r)/r)·t)
The first term in each line is the position of the rolling circle's centre as it goes around the ring; the second term is the pen swinging around that moving centre. Add them together and you get the looping path. A computer just evaluates this for thousands of tiny steps of t and joins the dots — which is why the curve appears to be drawn by an invisible rolling circle.
Why ratios decide the shape
Here is the heart of why spirographs are endlessly varied: the shape depends almost entirely on the ratio between R and r, not their absolute sizes. That ratio decides how many times the rolling circle spins as it makes one trip around the ring, and therefore how many loops or points the pattern has.
| Ratio R : r | Result |
|---|---|
| Small whole number (2:1, 3:1) | A few clean loops or petals |
| Larger whole number (7:2) | More points, tighter symmetry |
| Nearly coprime (e.g. 97:64) | Dense, web-like, many revolutions |
Mathematically, the curve closes — returns exactly to where it began — after a number of loops equal to r divided by the greatest common divisor of R and r. If R and r share a big common factor, the pattern closes quickly and looks simple. If they are nearly coprime (share no common factor), the pen must travel around dozens of times before closing, weaving those dense, hypnotic designs. Nudging a slider by one often changes a simple flower into an intricate star, which is exactly what makes the tool so absorbing to play with.
The pen offset: from circle to star
The third number, d, changes the character rather than the symmetry. With the pen right at the rolling circle's centre (d = 0), you just get a plain circle. Move it outward and the loops grow, reaching out toward the ring and back. Push it beyond the rolling circle's radius and the loops overshoot into sharp points and crossings. So d is your dial from soft, rounded petals to spiky, star-burst designs, while the R:r ratio sets how many of them there are.
Maths you can feel
Making patterns worth keeping
Once you are exploring freely, a few habits produce better results than random sliding. Change one parameter at a time so you can see what each does rather than jumping between unrelated designs. Note the numbers when something works, since a pattern you liked can be almost impossible to rediscover by chance. And export generously — the difference between two nearby settings is often striking, and the one you keep is rarely the first you tried.
For colour, the rainbow mode suits dense, many-looped designs because the gradual shift helps the eye follow individual passes through the tangle. A single colour tends to suit simpler patterns with fewer, cleaner loops, where the shape itself is the point and colour variation would only distract from it.
Curves that show up in the real world
These shapes are not confined to toys and screens. Guilloché engraving — the fine, interwoven curves on banknotes, passports, share certificates and the dials of expensive watches — is produced by machines working on exactly this principle, and it persists as a security feature precisely because such patterns are difficult to reproduce accurately without the same apparatus.
In engineering, the rounded-triangle rotor of a rotary engine traces one of these curves, and cycloidal gearing — used in clocks and precision drives — has tooth profiles derived from rolling-circle geometry because they transmit motion smoothly. Even the path a point on a rolling wheel traces along a road is a member of the same family. Once you know the shape, you start noticing it in machinery, ornament and currency alike, which is a small but genuine pleasure of understanding the mathematics behind a toy.
Generative art and the appeal of rules
A spirograph is a small, approachable example of generative art — work produced by defining a system and letting it run, rather than by placing every mark by hand. The artist chooses constraints; the process supplies the detail. That description covers everything from mid-century algorithmic plotter drawings to modern procedural landscapes and code-based artwork.
What makes the approach compelling is the ratio of input to output. Three numbers produce a design with thousands of intersections that no one could reasonably draw by hand, and small changes to those numbers produce entirely different results — so exploration feels like discovery rather than construction. You are not executing a vision you already had; you are searching a space and recognising something good when it appears.
It is also a gentle introduction to thinking like a programmer about images. Parameters, ratios and repetition are exactly the concepts underlying procedural graphics, and a spirograph makes them tangible without a line of code. If the patterns here hold your attention, the same instincts carry directly into creative coding, shader art and algorithmic design.
Epicycles: when the sky was drawn this way
There is a striking historical footnote to these curves. For roughly fourteen centuries the accepted model of the heavens was Ptolemaic, with the planets circling the Earth — and to explain why planets sometimes appear to reverse direction in the night sky, astronomers added epicycles: small circles whose centres travelled around larger circles. The resulting paths are, mathematically, precisely the family of curves a spirograph draws.
The model was wrong about what orbits what, yet remarkably good at prediction, and as observations improved astronomers stacked epicycles upon epicycles to preserve its accuracy. That history has an interesting modern echo: adding enough rotating circles can approximate essentially any closed curve, which is the same insight underlying Fourier analysis.
So when you slide the gears here and watch loops form within loops, you are manipulating the very mechanism medieval astronomers used to model the sky — and the same mathematics that now decomposes audio, images and signals of every kind.
The toy, and the mathematics that preceded it
The Spirograph most people remember was developed by the British engineer Denys Fisher and launched as a toy in 1965, where it became an immediate international hit and a fixture of childhoods for decades. Fisher's background was not in toys at all — he had been designing components for NATO, and arrived at the gear mechanism while working on drafting equipment.
The mathematics, though, is centuries older. Curves generated by rolling circles were studied by mathematicians including Albrecht Dürer, who described epicycloids in the early 1500s, and later by Newton and Euler. There were even earlier drawing instruments: nineteenth-century engineers built elaborate geometric chucks and "rose engines" that cut spirograph-like patterns into metal and wood, a technique called guilloché still used in watch dials and — notably — in the intricate background patterns of banknotes, precisely because such curves are hard to reproduce by hand.
A family of related curves
The hypotrochoid is one member of a family, and the differences come down to two choices: whether the small circle rolls inside or outside, and where the pen sits.
| Curve | Rolls | Pen position |
|---|---|---|
| Hypotrochoid | Inside | Anywhere (the classic spirograph) |
| Hypocycloid | Inside | On the rim — makes pointed cusps |
| Epitrochoid | Outside | Anywhere — flower-like petals |
| Cardioid | Outside, equal circles | On the rim — a heart shape |
Two special cases are worth knowing because they show up unexpectedly. When the rolling circle is exactly half the size of the ring, the hypocycloid collapses into a perfectly straight line — a surprising result known as the Tusi couple, described by a Persian astronomer in the 13th century and once used to model planetary motion. And an epitrochoid where the rolling circle is a third of the fixed one produces the rounded-triangle shape used as the rotor in the Wankel rotary engine, which is a genuinely practical application of these curves.
Settings to explore
Rather than sliding randomly, a few deliberate combinations show the mathematics clearly:
- Ring exactly twice the gear. Watch the curve flatten dramatically — the Tusi-couple effect.
- Ring three or four times the gear. Clean three- and four-petal flowers; the petal count matches the ratio.
- Pen offset at zero. A plain circle, confirming that d alone creates all the looping.
- Pen offset larger than the gear. Loops overshoot into sharp, crossing star points.
- Nudge the gear by one. A neat flower turns into a dense web — this is the greatest-common-divisor effect in action.
That last experiment is the most instructive. Changing a single unit alters whether the two numbers share a factor, which changes how many revolutions the pen takes before closing — and therefore transforms a simple pattern into an intricate one with no other change at all.
Where the appeal comes from
There is something particular about the pleasure of these patterns, and it is not just novelty. Spirograph curves have rotational symmetry — the design repeats at regular angles around the centre — and the human visual system is strongly drawn to symmetry, which we perceive as order and beauty across cultures. The curves also produce moiré-like interference where dense lines overlap, creating apparent shapes that are not drawn at all but emerge from the spacing.
This is also why spirographs have such a strong association with meditative focus. The output is complex but the input is simple, so you get an unusually high ratio of visual reward to effort — the same quality that makes generative art appealing more broadly. You are not really drawing; you are choosing constraints and letting mathematics do the rendering, which is a genuinely different creative experience from putting a pen to paper.
In short: the ring-to-gear ratio decides how many loops you get, the pen offset decides how sharp they are, and everything else is exploration. Part of the joy of a spirograph is that it makes an abstract idea tangible: you are literally watching parametric equations, gear ratios and the greatest common divisor draw themselves. It is a lovely on-ramp to deeper topics — parametric curves, periodicity, number theory — hiding inside something that just looks pretty. Slide the gears, hit random, and export the ones you love in theSpirograph— every curve computed live in your browser.