Mercurial > code > home > repos > light9
comparison flax/Timeline.py @ 206:851cf44cea40
rename clientid and allow it as an argument
author | drewp |
---|---|
date | Sun, 10 Apr 2005 15:13:48 +0000 |
parents | 83e2c4ceb79a |
children |
comparison
equal
deleted
inserted
replaced
205:3905d3c92aaa | 206:851cf44cea40 |
---|---|
1 from TLUtility import make_attributes_from_args, dict_scale, dict_max, \ | 1 from TLUtility import make_attributes_from_args, dict_scale, dict_max, \ |
2 DummyClass, last_less_than, first_greater_than | 2 DummyClass, last_less_than, first_greater_than |
3 from time import time | 3 from time import time |
4 import random | |
4 from __future__ import division # "I'm sending you back to future!" | 5 from __future__ import division # "I'm sending you back to future!" |
5 | 6 |
6 """ | 7 """ |
7 Quote of the Build (from Ghostbusters II) | 8 Quote of the Build (from Ghostbusters II) |
8 Dana: Okay, but after dinner, I don't want you putting any of your old cheap | 9 Dana: Okay, but after dinner, I don't want you putting any of your old cheap |
145 period_time = time_since_startframe % self.cycletime | 146 period_time = time_since_startframe % self.cycletime |
146 if period_time <= self.ontime: | 147 if period_time <= self.ontime: |
147 return {endframe.frame : self.onlevel} | 148 return {endframe.frame : self.onlevel} |
148 else: | 149 else: |
149 return {endframe.frame : self.offlevel} | 150 return {endframe.frame : self.offlevel} |
151 | |
152 class Sine(Blender): | |
153 "Strobes the frame on the right side between offlevel and onlevel." | |
154 def __init__(self, period, onlevel=1, offlevel=0): | |
155 "times are in seconds (floats)" | |
156 make_attributes_from_args('period', 'onlevel', 'offlevel') | |
157 def __call__(self, startframe, endframe, blendtime, time_since_startframe): | |
158 sin = math.sin(time_since_startframe / self.period * 2 * math.pi) | |
159 zerotoone = (sin / 2) + 0.5 | |
160 level = offlevel + (zerotoone * (onlevel - offlevel)) | |
161 return {endframe.frame : level} | |
162 | |
163 class RandomStrobe(Blender): | |
164 def __init__(self, minwaitlen=0.1, maxwaitlen=0.6, burstlen=0.14, \ | |
165 burstintensity=1, offintensity=0.05, tracklen=500): | |
166 "times are in seconds (floats)" | |
167 make_attributes_from_args('burstlen', 'burstintensity', 'offintensity') | |
168 self.burstintervals = [] | |
169 timecursor = 0 | |
170 | |
171 while timecursor < tracklen: | |
172 waitlen = minwaitlen + (random.random() * (maxwaitlen - minwaitlen)) | |
173 timecursor += waitlen | |
174 self.burstintervals.append((timecursor, timecursor + burstlen)) | |
175 def __call__(self, startframe, endframe, blendtime, time_since_startframe): | |
176 found_burst = 0 | |
177 for intstart, intend in self.burstintervals: | |
178 if intstart <= time_since_startframe <= intend: | |
179 found_burst = 1 | |
180 break | |
181 | |
182 if found_burst: | |
183 return {endframe.frame : self.burstintensity} | |
184 else: | |
185 return {endframe.frame : self.offintensity} | |
150 | 186 |
151 class TimelineTrack: | 187 class TimelineTrack: |
152 """TimelineTrack is a single track in a Timeline. It consists of a | 188 """TimelineTrack is a single track in a Timeline. It consists of a |
153 list of TimedEvents and a name. Length is automatically the location | 189 list of TimedEvents and a name. Length is automatically the location |
154 of the last TimedEvent. To extend the Timeline past that, add an | 190 of the last TimedEvent. To extend the Timeline past that, add an |