-
Notifications
You must be signed in to change notification settings - Fork 0
/
roads.py
56 lines (52 loc) · 1.16 KB
/
roads.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
from plot import Plot
import random
def make_road_straight(p: Plot, size):
p.pendown()
p.forward(size/3)
p.right(90)
p.forward(size)
p.right(90)
p.forward(size/3)
p.right(90)
p.forward(size/3)
p.right(90)
p.forward(size/3)
p.penup()
p.forward(size/3)
p.pendown()
p.forward(size/3)
p.right(90)
p.forward(size/3)
p.right(90)
p.forward(size/3)
p.right(90)
p.forward(size)
p.right(90)
p.forward(size/3)
p.right(90)
p.forward(size/3)
p.right(90)
p.forward(size/3)
p.penup()
p.forward(size/3)
p.pendown()
p.forward(size/3)
p.right(90)
p.forward(size/3)
def main(p: Plot):
p.plot_size = 4
p.setup()
p.draw_bounding_box()
grid_size = 20
padding = 0.5
spacing = (100-padding)/grid_size
size = spacing - padding
for r in range(grid_size):
for c in range(grid_size):
p.goto(padding+c*spacing, size+padding+r*spacing)
p.set_angle(0)
p.penup()
for _ in range(random.randint(0, 3)):
p.forward(size)
p.right(90)
make_road_straight(p, size)