-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday18.py
101 lines (79 loc) · 1.84 KB
/
day18.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# Day 18: More graphics with turtle
##################################
import turtle as t
timmy = t.Turtle()
timmy.shape("turtle")
# timmy.color("red")
# Challenge 1: draw sqaure
# for _ in range(4):
# timmy.forward(100)
# timmy.right(90)
#
# screen = t.Screen()
# screen.exitonclick()
# Challenge 2: Draw a dashed line
# for _ in range(15):
# timmy.forward(10)
# timmy.penup()
# timmy.forward(10)
# timmy.pendown()
#
# screen = t.Screen()
# screen.exitonclick()
# Challenge 3: Drawing different shapes
import random
colors = ["CornflowerBlue", "DarkOrchid", "IndianRed", "DeepSkyBlue", "LightSeaGreen", "wheat", "SlateGray", "SeaGreen"]
# timmy.forward(100)
#
# for i in range(3, 10):
# angle = 360 / i
#
# for _ in range(i):
# timmy.right(angle)
# timmy.forward(100)
#
# timmy.color(random.choice(colors))
#
#
# screen = t.Screen()
# screen.exitonclick()
# Challenge 4: Random walk
timmy.pensize(10)
timmy.speed(10)
angles = [0, 90, 180, 270]
# for _ in range(100):
# timmy.right(random.choice(angles))
# timmy.forward(20)
# timmy.color(random.choice(colors))
#
#
# screen = t.Screen()
# screen.exitonclick()
# Challenge 5: Random RGB colors
# t.colormode(255) # change colormode to rgb
#
# def random_color():
# r = random.randint(0, 255)
# g = random.randint(0, 255)
# b = random.randint(0, 255)
# random_color = (r, g, b)
# return random_color
#
# for _ in range(100):
# timmy.right(random.choice(angles))
# timmy.forward(20)
# timmy.color(random_color())
#
#
# screen = t.Screen()
# screen.exitonclick()
# Challenge 6: Spirograph
timmy.pensize(1)
timmy.speed(15)
for _ in range(36): # 360 degrees / 10 degrees is gap
timmy.color(random.choice(colors))
timmy.circle(100)
timmy.right(10)
timmy.circle(100)
screen = t.Screen()
screen.exitonclick()