Skip to content

Turtle-graphics art generator that draws colorful spirograph patterns with randomized radii and angles.

Notifications You must be signed in to change notification settings

AliCodesDev/spirograph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Turtle Spirograph (Random-Color Circles)

A tiny Python program that uses the built-in turtle module to draw a spirograph-style pattern: 100 circles of radius 100, each rotated by 10°, with a new random RGB color every turn.

✨ What It Does

  • Draws concentric/overlapping circles, producing a spirograph effect.
  • Picks a new random RGB color for each circle.
  • Uses the fastest turtle speed for quick rendering.
  • Keeps the window open until you click.

🧩 How It Works (High-Level)

  1. Set up a Turtle named tim, enable 0–255 RGB mode with turtle.colormode(255), and set speed to "fastest".

  2. Define random_color() to return a random (r, g, b) tuple.

  3. Loop 100 times:

    • Change the pen color to a new random color.
    • Draw a circle of radius 100.
    • Rotate the turtle’s heading by 10 degrees (setheading(heading + 10)).
  4. Wait for a mouse click to close the window.

✅ Requirements

  • Python 3.8+ (any recent Python 3 works)
  • No external dependencies (uses the standard library)

▶️ Run It

Save the script as spirograph.py, then run:

python spirograph.py

On some systems you may need:

python3 spirograph.py

Click the window to exit when you’re done admiring the art.

🔧 Customize

Tweak these values to change the look:

  • Number of circles Increase or decrease the loop count:

    for _ in range(120):  # was 100
  • Circle size (radius)

    tim.circle(80)  # was 100
  • Rotation step (degrees per circle) Smaller steps create denser patterns; larger steps are more star-like:

    tim.setheading(tim.heading() + 5)   # denser
    tim.setheading(tim.heading() + 15)  # sparser
  • Speed "fastest" is ideal, but you can slow it down to watch the drawing:

    tim.speed(10)  # 1 (slow) to 10, or "fastest"
  • Color strategy Replace random_color() with a palette or gradient for themed visuals.

🐛 Troubleshooting

  • Blank/hidden window: Some IDEs buffer the turtle window behind others—look for a new window or run from a terminal.
  • Slow rendering: Keep "fastest", reduce the loop count, or increase the rotation step.
  • Colors look muted: Ensure turtle.colormode(255) is called before setting RGB colors.

📁 File Overview

  • spirograph.py — the drawing script (your code).

📜 Notes

  • This program uses only Python’s standard library—great for quick demos or teaching graphics fundamentals.
  • MIT License

Enjoy making mathematical doodles come alive!

About

Turtle-graphics art generator that draws colorful spirograph patterns with randomized radii and angles.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages