-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforest.py
More file actions
75 lines (43 loc) · 966 Bytes
/
Copy pathforest.py
File metadata and controls
75 lines (43 loc) · 966 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
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
import turtle
import math
import random
s = turtle.Screen()
s.screensize(5000, 5000)
s.title("forest at night")
s.bgcolor("black")
t = turtle.Turtle()
t.pencolor("white")
t.up()
t.backward(250)
t.down()
turtle.Screen().mainloop()
turtle.setworldcoordinates(-800, -800, 800, 800)
def draw_trunk(maxh):
height = random.randint(50, maxh)
t.left(90)
t.pendown()
t.forward(height)
t.backward(height)
t.right(90)
t.penup()
return height
def draw_polygon(sides):
t.pendown()
for i in range(sides):
t.forward(50)
t.left(360/sides)
t.penup()
def draw_circle(radius):
t.pendown()
t.circle(radius)
t.penup()
def gapbetweenthings():
t.forward(100)
def draw_star():
t.pendown()
for _ in range(8):
t.forward(20)
t.backward(20)
t.right(45)
t.penup()
draw_star()