Python and Turtle Difficulty Level 3,loop,random Vortex of Squares with Python Turtle (Source Code Included)

Vortex of Squares with Python Turtle (Source Code Included)

Draw the following spiral based on filled squares which changes the size as they rotate.

Vortex of Squares

Source Code:

import turtle
import random
turtle.speed(0)
turtle.setup(1000,1000)
turtle.title('Vortex of Filled Squares - PythonTurtle.Academy')
turtle.hideturtle()
def draw_square(x,y,size,tilt_angle,c):
    turtle.up()
    turtle.goto(x,y)
    turtle.down()
    turtle.seth(tilt_angle)
    turtle.fillcolor(c)
    turtle.begin_fill()
    for i in range(4):
         turtle.fd(size)
         turtle.left(90)
    turtle.end_fill()
angle=0
size=300
while size > 0:
    draw_square(0,0,size,angle,(random.uniform(0,1),random.uniform(0,1),random.uniform(0,1)))
    size -= 0.1
    angle+=3

2 thoughts on “Vortex of Squares with Python Turtle (Source Code Included)”

    1. 🙂 It was based your filled square spiral. Try to decrease the size of square from a big number (e.g. 200) down to 0 and see what it does.

Comments are closed.

Related Post