-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcool swirl.py
More file actions
65 lines (61 loc) · 1.44 KB
/
cool swirl.py
File metadata and controls
65 lines (61 loc) · 1.44 KB
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
55
56
57
58
59
60
61
62
63
64
65
import turtle
t = turtle.Turtle()
s = turtle.Screen()
s.bgcolor("pink")
t.pencolor("white")
t.pensize("5")
a = 0 # Starting size of the side of the square
b = 15 # Always turn 90 degrees to form a square
t.speed(0)
t.penup()
t.goto(0, 0) # Start from top-left corner to form the square
t.pendown()
t.fillcolor("aqua")
t.shape("turtle")
while True:
for _ in range(4): # Draw four sides of a square
t.forward(a) # Move forward by the length of a (side of the square)
t.right(b) # Turn 90 degrees after each side
a += 1 # Increase the side length to make the square grow large
if a > 10:
t.color("yellow")
if a > 20:
t.color("green")
if a > 30:
t.color("red")
if a > 40:
t.color("orange")
if a > 50:
t.color("blue")
if a > 60:
t.color("gray")
if a > 70:
t.color("sky blue")
if a > 80:
t.color("navy")
if a > 90:
t.color("cyan")
if a > 100:
t.color("black")
if a > 105:
t.color("white")
if a > 110:
t.color("yellow")
if a > 115:
t.color("red")
if a > 120:
t.color("orange")
if a > 125:
t.color("blue")
if a > 130:
t.color("gray")
if a > 135:
t.color("sky blue")
if a > 140:
t.color("navy")
if a > 145:
t.color("cyan")
if a > 150: # Stop once the square gets big enough
break
t.hideturtle()
turtle.done()