This illustrator script will draw simple spirograph pattern using 2 circles as an input.
A spirograph is a toy that uses straightforward mechanics to create a pleasing collection of curves that are formally referred to as roulette curves.
The inside edge of a large circle, which serves as the spirograph pattern’s outer border, is rolled by a small wheel without slipping. A pen is placed on the smaller wheel’s circumference or at another fixed location inside of it. The pen draws the roulette curve as the wheel spins.
The size ratio of the inner wheel to the outer circle and the location of the pen within the wheel are two factors that affect how the curve emerges. See how the curves change in shape by adjusting the settings listed above. These curves have a mathematical formula:
R is the radius of the exterior circle,
r is the radius of the small rolling wheel,
p is the position of the pen within the small rolling wheel (0-1),
θ measures distance along the curve.