Spirograph Drawer¶
By the end of this lab you'll be able to:
- Draw a family of hypotrochoid curves that animate one after another
- Use a list of parameter sets to create a sequence of different Spirograph patterns
- Understand how changing
R,r, anddproduces completely different shapes
A Spirograph drawer that cycles through 6 different parameter sets, drawing each one in a different color to build up a layered display of overlapping hypotrochoid curves.
Welcome to the Spirograph Drawer!
In this lab the Spirograph draws itself — cycling through 6 different
parameter sets automatically, building up a layered display!
Let's code it together!
How It Works¶
A list of (R, r, d, color) tuples defines 6 Spirograph parameter sets. The outer loop iterates through them; the inner loop draws each hypotrochoid. tracer(0) and update() keep the animation smooth.
Sample Code¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | |
What Do You Think Will Happen?
Six different parameter sets in six different colors.
Will the curves overlap neatly, or will they create a chaotic jumble?
Make your guess — then click Run to find out!
Try It Now¶
Six colorful Spirograph curves, each with a different shape, building up a layered composition. Were you right about the overlap?
How It Works¶
Each (R, r, d) triple produces a completely unique curve. Because all curves are drawn from the same center, they overlap like layers in a painting. The if i % 50 == 0: screen.update() updates the display every 50 points to show the drawing progress.
Explanation Table¶
| Line | What it does |
|---|---|
params = [...] |
List of (R, r, d, color) tuples |
for R, r, d, color in params |
Unpack each parameter set |
if i % 50 == 0: screen.update() |
Show progress every 50 steps |
screen.tracer(0) |
Manual control over screen refresh |
Learning Check¶
Your Turn — Design Your Own Set
Replace the params list with 3 parameter sets of your own choosing.
Try to make curves that each have different numbers of loops (R/r ratio determines it).
What ratios will you pick?
With the same R=120 and d=80 but different r values (40, 24, 15), the three curves have 3, 5, and 8 loops respectively — matching R/r.
Experiments¶
-
Add more curves. Extend
paramsto 10 entries. You'll know it worked when a denser, more colorful composition appears. -
Use pastel colors. Replace the colors with lighter shades. You'll know it worked when the overlapping curves produce a softer appearance.
-
Clear and redraw. Add
screen.clearscreen()between curves — only one at a time. You'll know it worked when each curve appears alone before the next one. -
Vary the step count. Use more steps for higher
R/rratios. You'll know it worked when complex curves look smoother.
Art Machine!
Your code generates art automatically from a list of parameters — an art machine!
This is the essence of generative art: code that produces visuals from rules.
Up next: Category 11 — Advanced Patterns!