-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspirograph.py
More file actions
32 lines (23 loc) · 789 Bytes
/
spirograph.py
File metadata and controls
32 lines (23 loc) · 789 Bytes
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
import random
import time
from turtle import Turtle, Screen
def change_color():
new_color = (random.randint(1, 255), random.randint(1, 255), random.randint(1, 255))
return new_color
my_screen = Screen()
timmy = Turtle()
timmy.speed("fastest")
def draw_spirograph(gap, num_cir):
for _ in range(num_cir):
timmy.color(change_color())
timmy.circle(100)
timmy.right(gap)
for count in range(10, 0, -1):
my_screen.colormode(255)
number_of_circles = int(360 / count)
my_screen.title(f"Spirograph gap = {count}º. Number of circles = {number_of_circles}.")
draw_spirograph(count, number_of_circles)
time.sleep(1)
my_screen.clear()
my_screen.title(f"Click screen to exit!")
my_screen.exitonclick()