How to use the spirograph pattern generator
- Pick whether the rolling circle runs inside or outside the fixed circle, or start from an example button.
- Enter the fixed circle radius R, the rolling circle radius r (both whole numbers) and the pen distance d.
- Choose the colors, line width and background.
- Check the turns and lobes shown under the picture, then download an SVG or PNG.
Formula
Inside: x = (R - r) cos t + d cos((R - r) t / r), y = (R - r) sin t - d sin((R - r) t / r)
Outside: x = (R + r) cos t - d cos((R + r) t / r), y = (R + r) sin t - d sin((R + r) t / r)
Turns to close = r / gcd(R, r); lobes = R / gcd(R, r)
Points drawn = turns x 360, plus one to close the curve
The pen sits distance d from the center of the rolling circle. At d equal to r the pen is on the rim and the curve has sharp points. If d is smaller the curve is smooth, and if larger it forms loops.
Three patterns
R = 90, r = 36 and d = 60 inside: the greatest common divisor is 18, so the curve closes after 36 / 18 = 2 turns and has 90 / 18 = 5 lobes, like a five-pointed star. R = 60, r = 20 and d = 30 outside has a common divisor of 20, so it closes after 1 turn with 3 lobes, a rounded flower with three petals.
R = 105, r = 30 and d = 52 inside has a common divisor of 15, so it closes after 2 turns with 7 lobes. Radii with no common factor, such as 97 and 29, need 29 turns and make a dense lace pattern. Pairs needing more than 100 turns are refused so the picture stays drawable.
How the curve is drawn
Imagine a small gear rolling around inside a large ring, with a pen in a hole at distance d from the small gear's center. The path of the pen is a hypotrochoid. Rolling the small circle around the outside gives an epitrochoid. Because both radii are whole numbers, the curve joins up with itself after a whole number of turns, which the tool computes from their greatest common divisor.
For other shapes from circles see the circle calculator, for color schemes the color palette generator, and for related pattern work the Pythagorean triples generator and the cellular automaton generator.
Colors and files
The one-color setting draws a single path. The rainbow, warm and cool settings split the path into segments and color them in order, so you can follow the pen's route. The SVG is a vector file that stays sharp at any size, and the PNG is drawn at 1600 by 1600 pixels. Everything is made in your browser and nothing is uploaded.
Assumptions and limits
- R and r are whole numbers (R from 2 to 300, r from 1 to 300) and the pen distance d is any number from 0 to 300.
- For a circle rolling inside, r must be smaller than R.
- The pattern is drawn with 360 points per turn, which is smooth for sizes up to a few hundred.
- Line colors are chosen from a short list, and the background is white or dark.
Frequently asked questions
How do I make a spirograph pattern?
Choose a fixed radius R and a smaller rolling radius r, then set a pen distance d. Different combinations make different stars and flowers. The example buttons give three starting points.
Why does the pattern need a common divisor?
The pen returns to its start only when the rolling circle has gone a whole number of times around the fixed one. That takes r / gcd(R, r) turns, so radii with a large common divisor give a simple pattern with few turns.
What is the difference between inside and outside?
Inside rolls the small circle within the ring, making a hypotrochoid with inward points. Outside rolls it around the outer edge, making an epitrochoid with rounded loops pointing outward.
How do I change the number of petals?
The number of lobes is R divided by the greatest common divisor of R and r. With R = 90 and r = 36 you get 5, and changing r to 30 gives 3.