Skip to content

Commit d6773e7

Browse files
committed
Basic rocket timeline
1 parent 03b36df commit d6773e7

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

demosys/timeline/rocket.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from .base import BaseTimeline
2+
3+
4+
class Timeline(BaseTimeline):
5+
"""
6+
At attempt to use rocket data as our timeline.
7+
We use rocket track values of 0 and 1 deciding if the effect should be active.
8+
Only runnable effects will be used.
9+
Each effect should also have some way to specify its draw priority
10+
11+
The following class attributes must be specified on the effect:
12+
13+
rocket_timeline_track = Track instance
14+
rocket_timeline_order = 0
15+
16+
Effects are drawn in the user-defined order.
17+
18+
We might want to eventually convert this timeline data into a more managable format
19+
internally in the timeline because rocket tracks are not ideal for
20+
"""
21+
def __init__(self, project, *args, **kwargs):
22+
super().__init__(project)
23+
24+
# Get all runnable effect sorting them by rocket_timeline_order
25+
self.effects = self._project.get_runnable_effects()
26+
self.effects.sort(key=lambda x: x.rocket_timeline_order)
27+
28+
def draw(self, time, frametime, target):
29+
"""
30+
Fetch track value for every runnable effect.
31+
If the value is > 0.5 we draw it.
32+
"""
33+
for effect in self.effects:
34+
value = effect.rocket_timeline_track.time_value(time)
35+
if value > 0.5:
36+
effect.draw(time, frametime, target)

0 commit comments

Comments
 (0)