-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcanvastest.py
More file actions
79 lines (57 loc) · 1.68 KB
/
canvastest.py
File metadata and controls
79 lines (57 loc) · 1.68 KB
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
import math
import perlin_noise
from insutil import PaperCanvas
noise = perlin_noise.PerlinNoise(octaves=6, seed=6)
x_margin = 20
start_x = x_margin
end_x = 210 - x_margin
x = start_x
y = 30
wave_samples = 400
rows = 60
noise_scale = 25
pc = PaperCanvas(x, y, (754 - 210) / 1.98, 192.0, 754)
print(f"lb:{pc.lb} rb:{pc.rb}")
pc.goto(x, y)
pc.sample()
def land_function(i, total_i):
return 20 * math.sin((i / total_i) * (math.pi * 4)) + 5 * math.cos((i / total_i) * (math.pi * 3.234))
for py in range(0, rows):
for px in range(0, wave_samples):
pc.goto(x, y + noise([0.2 + px / wave_samples, py / rows]) * noise_scale)
pc.sample()
x += (1 / wave_samples) * (end_x - start_x)
y += 1.1
pc.goto(x, y)
pc.sample()
for px in range(0, wave_samples):
pc.goto(x, y + noise([ 1.9 + px / wave_samples, py / rows]) * noise_scale)
pc.sample()
x -= (1 / wave_samples) * (end_x - start_x)
y += 1.1
pc.goto(x, y)
pc.sample()
"""
for h in range(0, 10):
for i in range(0, wave_samples):
pc.goto(x, y + land_function(i, wave_samples))
print(y + math.sin(x))
pc.sample()
x += (1 / wave_samples) * (end_x - start_x)
for i in range(0, 10):
y += h / 10
pc.goto(x, y)
pc.sample()
for i in range(0, wave_samples):
pc.goto(x, y + land_function(wave_samples - 1 - i, wave_samples))
print(y + math.sin(x))
pc.sample()
x -= (1 / wave_samples) * (end_x - start_x)
for i in range(0, 10):
y += h / 10
pc.goto(x, y)
pc.sample()
"""
ins = pc.gen_instructions()
with open("../sim-rs/ins.json", "w") as fp:
fp.write(ins)