Generative Art Loop¶
By the end of this lab you'll be able to:
- Combine multiple turtle techniques — spirals, color cycling, polar coordinates — into one flowing program
- Use a parameter loop to automatically generate a family of related images
- Understand generative art: code that produces unique visual output governed by rules
The grand finale of the gallery — a generative art loop that combines spirals, color cycling, golden-angle placement, and parametric curves to produce a unique, complex composition each time the seed changes.
Welcome to the Generative Art Loop!
You've made it to the final lab in the gallery!
This program combines every technique from the gallery into one composition.
Every seed produces a different artwork — let's code the art machine!
How It Works¶
The program runs three layers:
- Golden spiral dots — 300 colored dots placed by the golden angle
- Parametric rose — a rose curve overlaid in semi-transparent white
- Nested spirals — 6 mini-spirals at positions computed from the rose curve
Together they form a complex, layered composition.
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
What Do You Think Will Happen?
Three layers — golden dots, a rose curve, and 6 mini-spirals — all centered together.
Will the layers look separate and cluttered, or will they combine into a unified image?
Make your guess — then click Run to find out!
Try It Now¶
A complex layered composition — the three layers interweave to form a unified artwork. Were you right?
How It Works¶
The golden dots fill the background with color texture. The rose curve provides structural geometry. The mini-spirals add focal points at the rose's petal positions. When all three layers share the same center and coordinate system, they naturally compose together.
Explanation Table¶
| Line | What it does |
|---|---|
golden = 137.508 |
Golden angle — optimally spaced dots |
math.cos(k * theta) |
Rose curve — 5 petals at k=5 |
arm * 60 |
Six arms at 60° spacing |
palette[n % len(palette)] |
Cycling color assignment |
Learning Check¶
Your Turn — Change the Seed
Change seed = 7 to seed = 99.
Predict: which part of the composition will change? (Not all three layers use random!)
Run it to find out which layers are deterministic and which are random.
Blue palette, 7-petaled rose, 7 spiral arms — a completely different but equally structured composition.
Experiments¶
-
Use a dark background. Add
turtle.bgcolor('black')and change the palette to bright colors. You'll know it worked when the dots glow against the dark background. -
Try k=8 for the rose. Change
k = 5tok = 8. Remember: even k gives 2k petals = 16 petals! You'll know it worked when a more complex rose appears. -
Add a fourth layer. Add a Lissajous figure drawn over the top in white. You'll know it worked when a third kind of curve joins the composition.
-
Loop through seeds 1–6. Clear the screen between seeds and draw six variants automatically. You'll know it worked when 6 different compositions are generated in sequence.
You Completed the Gallery!
You made it through all 100 turtle graphics patterns — from a simple square spiral
to a layered generative artwork! You've learned loops, functions, recursion, fractals,
parametric math, L-systems, and so much more. Keep coding — the canvas is infinite!