-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsample_targeted_animation.py
105 lines (93 loc) · 3.42 KB
/
sample_targeted_animation.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
102
103
104
105
import sculpy
class SampleTargetedAnimation(sculpy.TargetedAnimation):
def __init__(self, row_count, column_count):
super().__init__(row_count, column_count)
self.patterns = []
offset = -40000.0
distance = 2000.0
top = offset
bottom = top - distance
# Alternating rows 1
pattern = []
for row in range(0, row_count):
pattern_row = []
for column in range(0, column_count):
if row % 2 == 0:
pattern_row.append(top)
else:
pattern_row.append(bottom)
pattern.append(pattern_row)
self.patterns.append(pattern)
# Alternating rows 2
pattern = []
for row in range(0, row_count):
pattern_row = []
for column in range(0, column_count):
if row % 2 == 0:
pattern_row.append(bottom)
else:
pattern_row.append(top)
pattern.append(pattern_row)
self.patterns.append(pattern)
# Checkerboard 1
pattern = []
for row in range(0, row_count):
pattern_row = []
for column in range(0, column_count):
if row % 2 == 0:
if column % 2 == 0:
pattern_row.append(top)
else:
pattern_row.append(bottom)
else:
if column % 2 == 0:
pattern_row.append(bottom)
else:
pattern_row.append(top)
pattern.append(pattern_row)
self.patterns.append(pattern)
# Checkerboard 2
pattern = []
for row in range(0, row_count):
pattern_row = []
for column in range(0, column_count):
if row % 2 == 0:
if column % 2 == 0:
pattern_row.append(bottom)
else:
pattern_row.append(top)
else:
if column % 2 == 0:
pattern_row.append(top)
else:
pattern_row.append(bottom)
pattern.append(pattern_row)
self.patterns.append(pattern)
# Alternating columns 1
pattern = []
for row in range(0, row_count):
pattern_row = []
for column in range(0, column_count):
if column % 2 == 0:
pattern_row.append(top)
else:
pattern_row.append(bottom)
pattern.append(pattern_row)
self.patterns.append(pattern)
# Alternating columns 2
pattern = []
for row in range(0, row_count):
pattern_row = []
for column in range(0, column_count):
if column % 2 == 0:
pattern_row.append(bottom)
else:
pattern_row.append(top)
pattern.append(pattern_row)
self.patterns.append(pattern)
def get_next_targets(self, timestamp, time_delta, current_targets):
# Index will increment every 2 seconds and wrap through the range [0, len(self.patterns)]
index = int(timestamp / 2.0) % len(self.patterns)
pattern = self.patterns[index]
return pattern
ANIMATION_CLASS = SampleTargetedAnimation