-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerator.py
53 lines (49 loc) · 1.85 KB
/
generator.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
#!/usr/bin/env python3
import math
import random
def gen_single_rotation(filename):
CANVAS_ORIGIN = (-200, -200)
CANVAS_DIMS = (400, 400)
with open(filename, 'w') as out:
out.write("canvas {} {} {} {}\n".format(*CANVAS_ORIGIN, *CANVAS_DIMS))
out.write("shape R rectangle\n")
angle = 0
x, y = 0, 0
w, h = 300, 100
r, g, b = 200, 100, 200
for t in range(1, 301, 10):
line = "motion R "
line += "{} {} {} {} {} {} {} {} {:.2f} ".format(t, x, y, w, h, r, g, b, angle)
angle += math.pi * math.sin(t) + random.random()
line += "{} {} {} {} {} {} {} {} {:.2f}".format(t+10, x, y, w, h, r, g, b, angle)
out.write(line + '\n')
print("Done!")
def gen_combo_rotation(filename):
CANVAS_ORIGIN = (0, 0)
CANVAS_DIMS = (400, 400)
with open(filename, 'w') as out:
out.write("canvas {} {} {} {}\n".format(*CANVAS_ORIGIN, *CANVAS_DIMS))
out.write("shape R rectangle\n")
angle = 0
x, y = 50, 150
w, h = 300, 100
r, g, b = 200, 100, 200
for t in range(1, 301, 10):
line = "motion R "
line += "{} {} {} {} {} {} {} {} {:.2f} ".format(t, x, y, w, h, r, g, b, angle)
w += int(50 * (random.random() - 0.5))
h += int(50 * (random.random() - 0.5))
r += 10
r %= 255
g -= 2
g %= 255
b += 5
b %= 255
x += int(50 * (random.random() - 0.5))
y += int(50 * (random.random() - 0.5))
angle += math.pi * math.sin(t) + random.random()
line += "{} {} {} {} {} {} {} {} {:.2f}".format(t+10, x, y, w, h, r, g, b, angle)
out.write(line + '\n')
print("Done!")
gen_single_rotation("simple-geometry.txt")
gen_combo_rotation("combo-geometry.txt")