-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
73 lines (57 loc) · 1.6 KB
/
main.py
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
66
67
68
69
70
71
72
73
# Copyright (c) 2024 Jarid Prince
from days.day_018.files.helpers import *
def day_018():
title("TURTLE ART")
nls("Watch the art! :)")
nls(f"{bcolors.FAIL}DO NOT CLOSE WINDOW UNTIL COMPLETE{bcolors.ENDC}")
try:
screen = Screen()
screen = setup_screen(screen)
timmy = Turtle()
timmy = setup_timmy(timmy)
set_timmy_movement(timmy)
go(timmy, 10)
cleanup(timmy, screen)
except Exception as e:
screen = Screen()
screen = setup_screen(screen)
timmy = Turtle()
timmy = setup_timmy(timmy)
set_timmy_movement(timmy)
go(timmy, 10)
cleanup(timmy, screen)
def setup_timmy(timmy):
timmy.hideturtle()
timmy.speed("fastest")
timmy.pencolor("white")
timmy.penup()
return timmy
def setup_screen(screen):
screen.title("Turtle Art")
rootwindow = screen.getcanvas().winfo_toplevel()
rootwindow.call("wm", "attributes", ".", "-topmost", "1")
screen.colormode(255)
return screen
def set_timmy_movement(timmy):
timmy.setheading(225)
timmy.forward(320)
timmy.setheading(360)
def set_new_color(colors):
a = random.choice(colors)
return a
def go(timmy, times):
for _ in range(0, times):
for _ in range(10):
timmy.dot(20, set_new_color(COLORS_IN_IMAGE))
timmy.forward(50)
timmy.setheading(90)
timmy.forward(50)
timmy.setheading(180)
timmy.forward(500)
timmy.setheading(0)
def cleanup(timmy, screen):
timmy.clear()
screen.clear()
screen.bye()
del timmy
del screen