Created
February 25, 2013 17:38
-
-
Save ptone/5031614 to your computer and use it in GitHub Desktop.
the code behind http://www.youtube.com/watch?v=Z2eyb_pqH0E
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from birdfish.input.osc import OSCDispatcher | |
from birdfish.lights import RGBLight, Chase, LightShow | |
from birdfish.output.lumos_network import LumosNetwork | |
from birdfish import tween | |
osc_dispatcher = OSCDispatcher(('0.0.0.0', 8998)) | |
# create a light show - manages the updating of all lights | |
show = LightShow() | |
# Create a network - in this case, universe 3 | |
dmx3 = LumosNetwork(3) | |
# add the network to the show | |
show.networks.append(dmx3) | |
class ColorTriggerChase(Chase): | |
def __init__(self, *args, **kwargs): | |
super(ColorTriggerChase, self).__init__(*args, **kwargs) | |
self.target_hue = 0 | |
def render(self): | |
""" | |
This is mostly copy and paste from the Chase render method | |
but it changes the hue of those elements being triggered | |
""" | |
if self.last_center is None: | |
self.last_center = self.start_pos | |
current_center = int(self.center_position) | |
if self.sweep: | |
if self.last_center > current_center: | |
trigger_elements = self.elements[current_center:self.last_center] | |
else: | |
trigger_elements = self.elements[self.last_center:current_center] | |
for e in trigger_elements: | |
e.hue = self.target_hue | |
e.trigger(self.trigger_intensity) | |
self.last_center = current_center | |
simple = ColorTriggerChase(name="simplechase") | |
elementid = 0 | |
for i in range(1, 360, 3): | |
elementid += 1 | |
l = RGBLight( | |
start_channel=i, | |
name="item_%s" % elementid, | |
attack_duration=0.2, | |
decay_duration=0, | |
release_duration=1, | |
release_shape=tween.OUT_CIRC, | |
sustain_value=1, | |
) | |
l.saturation = 1 | |
l.bell_mode = True | |
dmx3.add_element(l) | |
simple.elements.append(l) | |
simple.start_pos = 12 | |
simple.speed = .1 | |
simple.moveto = simple.end_pos = 65 | |
show.add_element(simple) | |
osc_dispatcher.add_trigger('/3/toggle1', simple) | |
osc_dispatcher.add_map('/3/xy', simple, 'target_hue', data_member=1) | |
osc_dispatcher.add_map('/3/xy', simple, 'move_toward', out_range=(12, 65)) | |
osc_dispatcher.start() | |
# start the show in a try block so that we can catch ^C and stop the input threads | |
if __name__ == '__main__': | |
try: | |
show.run_live() | |
except KeyboardInterrupt: | |
# cleanup | |
osc_dispatcher.stop() | |
sys.exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment