Ever wondered what happens when you code geometric shapes that keep growing and spinning? You get mesmerizing spirals that are both mathematically elegant and visually captivating.
This repo explores polygonal spirals using Python's built-in turtle graphics for interactive, educational, and artistic fun.
Great for beginners, educators, or anyone curious about creating generative art with code.
Each subfolder runs a classic or creative spiral:
- Color:
#229302 - Sides: 3
- Angle: 120°
- Loops: 500
- Color:
#9C026B - Sides: 5
- Angle: 72°
- Loops: 500
- Color:
cyan - Sides: 6
- Angle: 60°
- Loops: 2000
- Color:
#9C026B - Sides: 50 (almost a circle)
- Angle: 7.2°
- Loops: 20000
-
Clone the repo
git clone https://github.com/willow788/let-us-play-polygonal-spirals.git cd let-us-play-polygonal-spirals -
Pick a spiral
cd "Python Code Files/Triangle Code" # or Pentagon Code, or Hexagon Code, or Circle-like Code
-
Run it
python main.py
-
Enjoy the show!
Requires only Python 3 (no extra libraries needed; turtle is included in the standard library).
- Choose a polygon: triangle, pentagon, hexagon, or a high-sided "circle".
- Compute the turning angle:
360 / number_of_sides. - Start with an initial side length.
- Loop:
- Draw a side,
- Turn right by the angle,
- Increase the length.
- Repeat for hundreds or thousands of iterations.
sides = 6 # hexagon, for example
angle = 360 / sides
length = 2
for i in range(iterations):
turtle.forward(length)
turtle.right(angle)
length += 1let-us-play-polygonal-spirals/
├── Python Code Files/
│ ├── Triangle Code/
│ │ └── main.py
│ ├── Pentagon Code/
│ │ └── main.py
│ ├── Hexagon Code/
│ │ └── main.py
│ └── Circle-like Code/
│ └── main.py
├── Demonstration/
├── README.md
├── LICENSE
└── .gitignore
- Try different colors, drawing speeds, or background themes.
- Experiment with the side increment (change by more than 1, or use a non-linear increase).
- Combine multiple spirals for layered art.
- Add keyboard controls or interactive parameters.
MIT License — see LICENSE.
You are free to use, modify, and share.
Made with ❤️ by willow788
If these spirals delight you (or your inner child), give the repo a star!