Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

README.md

🌀 Spiral Galaxy Generator

I discovered that with just a few lines of Python, you can create these incredible galaxy-like spirals that look like something from deep space!

What you'll see

A bright yellow spiral that starts small and gradually expands outward, creating this mesmerizing pattern that looks like the arms of a galaxy. The cool part is how it builds up line by line - you can actually watch it being drawn in real time.

How to run this

# Make sure you have Python with tkinter (usually comes built-in)
python3 spiral-turtle.py

If you get an error about tkinter on Linux:

sudo apt update
sudo apt install python3-tk

How it works

This blew my mind when I realized how simple the math is! The secret is in just two variables:

  • a controls how far forward the turtle moves (gets bigger each step)
  • b controls how much it turns (also gets bigger each step)

So each step, the turtle moves a bit farther AND turns a bit more. That's what creates the expanding spiral effect. It's like the turtle is getting dizzy and taking bigger steps at the same time!

The magic happens in these two lines:

a += 3    # Move farther each time
b += 1    # Turn more each time

Try changing this

  • a += 3: Change the 3 to different numbers. Try 1, 5, or 10 to see how tight or loose the spiral gets
  • b += 1: Change this to 2 or 0.5 to see how the spiral arms change
  • t.pencolor("yellow"): Try "red", "cyan", "magenta" or any color you want
  • Challenge: Make it draw multiple spirals in different colors at the same time!

What I learned

Python can create graphics easily! The turtle module is built right into Python, so you don't need to install anything extra. This project taught me that sometimes the coolest visual effects come from really simple math - just adding numbers in a loop can create something that looks super complex.

Also learned that programming can be like art - tiny changes to the numbers create completely different patterns. It's like having a mathematical paintbrush!