# Dave: commented out because we don't want to give anybody a real seizure (epilepsy is real folks) # fm.FountainScene( # "full_seizure", # tags=[Scene.TAG_BACKGROUND], # background_effects=[SolidBackground(), SeizureMode()]), # Scene( # "seizure_mode", # tags=[Scene.TAG_BACKGROUND], # effects=[LaunchSeizure()]), # FiniteDifference does it's own button work Scene( "waves_of_diffusion", tags=[Scene.TAG_BACKGROUND, Scene.TAG_PRODUCTION], collaboration_manager=fm.ButtonToggleResponderManager(), effects=[ SolidBackground(color=(0xFF, 0, 0), start_col=0, end_col=2, start_row=30, end_row=34), #SolidBackground(color=(0,0xFF,0), start_col=0, end_col=2, start_row=120, end_row=124), FrameRotator(rate=0.5), RedGreenSquares(), FiniteDifference(master_station=0, boundary=FiniteDifference.NEUMANN, base_hue=0), fm.ButtonStationFaderFeedbackDisplay() ]), Scene( "wedding0", tags=[Scene.TAG_BACKGROUND, Scene.TAG_PRODUCTION], collaboration_manager=NoOpCollaborationManager(), effects=[ SolidBackground(color=(0xFF, 0, 0), start_col=0, end_col=2, start_row=120, end_row=124), SolidBackground( color=(0, 0xFF, 0), start_col=33, end_col=35, start_row=120, end_row=124), SolidBackground(color=(0xFF, 0, 0), start_col=0, end_col=2, start_row=30, end_row=34), SolidBackground(color=(0, 0xFF, 0), start_col=33, end_col=35, start_row=30, end_row=34),
def fill(self, pixels, time, coord, ii, osc_data): # TODO Check for existance of fade if osc_data.stations[5].faders[0] * self.row_scale > coord["row"]: pixels[ii] = tuple( [int(osc_data.stations[i].faders[0] * self.color_scale) for i in range(3)]) class SampleEffectLauncher(MultiEffect): def before_rendering(self, pixels, t, collaboration_state, osc_data): MultiEffect.before_rendering(self, pixels, t, collaboration_state, osc_data) for s in range(STATE.layout.sections): if osc_data.stations[s].buttons: self.launch_effect(t, s) def launch_effect(self, t, s): print "Adding Effect" per_section = int(STATE.layout.columns / STATE.layout.sections) e = ColumnStreak( column=randrange(0 + s * per_section, (s + 1) * per_section), color=(255, 0, 0)) self.effects.append(e) __all__ = [ Scene("spatial scene", NoOpCollaborationManager(), SpatialStripesBackground()), Scene("adjustablebackground", NoOpCollaborationManager(), SolidBackground(), AdjustableFillFromBottom()), Scene("launchdots", NoOpCollaborationManager(), SolidBackground((100, 100, 100)), SampleEffectLauncher()), ]
self.movement_function = movement_function if movement_function else no_movement def scene_starting(self, now): self.curr_row, self.curr_col = self.start_row, self.start_col def next_frame(self, pixels, now, collaboration_state, osc_data): # print map(lambda x: (x[0]+self.row, x[1]), self.indices) # pixels[map(lambda x: (x[0]+self.row, x[1]), self.indices)] = self.color # TODO Just pass this? self.movement_function(shape=self) frame_indices = cleanup_pairwise_indicies(self.indices+(self.curr_row, self.curr_col)) pixels.update_pairwise(additive=False, color=self.color, pairwise=frame_indices) def is_completed(self, t, osc_data): return self.curr_row >= STATE.layout.rows __all__ = [ Scene( "diamond", NoOpCollaborationManager(), SolidBackground(), Shape(indices=_diamond_indicies(4,4), movement_function=move_along_horizontal_sine_wave, start_row=20) ), Scene( "uptriangle", NoOpCollaborationManager(), SolidBackground(), Shape(movement_function=move_up, indices=_upward_triangle_indicies(height=5)) ) ]
for b in station.buttons: if station.client: update_buttons(station_id=s, client=station.client, updates={b: 2}, timeout=1) class NoOpCollaborationManager(CollaborationManager): """A no-op collaboration manager for when you need a placeholder in your scene""" def compute_state(self, t, collaboration_state, osc_data): pass # FIXME : A little hacky - trying to avoid circular dependencies on debugging_effects import debugging_effects __all__ = [ Scene("buttontoggler", ButtonToggleResponderManager(), SolidBackground(), debugging_effects.PrintOSC()), # A simple rainbow that rotates due to the FrameRotator Scene( "rotatingrainbow", NoOpCollaborationManager(), Rainbow(hue_start=0, hue_end=255), FrameRotator(rate=.75)), # A rainbow that has been distorted into spirals by using a RANGE as the offset Scene("funkrainbow", NoOpCollaborationManager(), Rainbow(hue_start=0, hue_end=255), FunctionFrameRotator( func=FunctionFrameRotator.sample_rotating_offset, start_offsets=range(STATE.layout.rows))), # A rainbow that follows a sine wave up (due to the offsets) and moves upwards due to a rolling offset function Scene("sinerainbow",
FOUNTAINS = [fm.FountainDefinition('streak', ColumnStreak)] SCENES = [ # These scenes are too slow # Scene( # "spatial scene", # tags=[Scene.TAG_BACKGROUND], # collaboration_manager=NoOpCollaborationManager(), # effects=[SpatialStripesBackground()]), # Scene( # "adjustablebackground", # tags=[Scene.TAG_EXAMPLE], # collaboration_manager=NoOpCollaborationManager(), # effects=[SolidBackground(), AdjustableFillFromBottom()]), # Removed in favor of fountaindots example # Scene( # "launchdots", # tags=[Scene.TAG_EXAMPLE], # collaboration_manager=NoOpCollaborationManager(), # effects=[SolidBackground(color=(30, 30, 30)), # SampleEffectLauncher()]), Scene( "fountaindots", tags=[Scene.TAG_EXAMPLE], # Not production collaboration_manager=NoOpCollaborationManager(), effects=[ SolidBackground(color=(30, 30, 30)), fm.FountainLaunchingController(fountain_pool=FOUNTAINS) ]) ]
for ii, c in [(int((spark_ii + x) % STATE.layout.n_pixels), 255 - x * 128 / self.spark_rad) for x in range(self.spark_rad)]: pixels[ii] = (c, c, c) class FailureEffect(Effect): """Force a failure after X frame""" def __init__(self, frames=30): self.frames = 30 def next_frame(self, pixels, now, collaboration_state, osc_data): self.frames -= 1 if self.frames < 0: raise Exception("Nobody expects me!") SCENES = [ Scene("osc printer", tags=[Scene.TAG_TEST], collaboration_manager=NoOpCollaborationManager(), effects=[SolidBackground(30, 30, 30)]), # Not a real effect. Just testing failures in effect code against the gulp server # Scene("failquick", NoOpCollaborationManager(), SolidBackground(0, 255, 0), FailureEffect()), Scene("bluewithdot", tags=[Scene.TAG_TEST], collaboration_manager=NoOpCollaborationManager(), effects=[SolidBackground(color=(0, 0, 255)), MovingDot()]) ]
end_col = end_col if end_col else STATE.layout.columns self.col_slice = slice(start_col, end_col) def scene_starting(self): self.curr_row = self.start_row def next_frame(self, pixels, now, collaboration_state, osc_data): pixels[self.curr_row, self.col_slice] = self.color self.curr_row += 1 def is_completed(self, t, osc_data): return self.curr_row >= STATE.layout.rows class LaunchRows(MultiEffect): def before_rendering(self, pixels, t, collaboration_state, osc_data): MultiEffect.before_rendering(self, pixels, t, collaboration_state, osc_data) for sid, station in enumerate(osc_data.stations): if station.buttons: self.add_effect( SolidRow(color=(randrange(0, 255), randrange(0, 255), randrange(0, 255)), start_col=11 * sid + randint(0, 11), end_col=11 * (sid + 1) + randint(0, 11))) __all__ = [ Scene("groupdemo", NoOpCollaborationManager(), SolidBackground(), LaunchRows()) ]
self.color = np.array(color, dtype=np.uint8) self.additive = additive def next_frame(self, pixels, now, collaboration_state, osc_data): # TODO : row limiter columns = self.picker(columns=range(STATE.layout.columns)) if self.additive: pixels[:, columns] += self.color else: pixels[:, columns] = self.color __all__ = [ Scene( "buttonchaser", ButtonChaseController(draw_bottom_layer=True), SolidBackground(), ButtonRainbow(max_value=255 - 30), Pulser()), Scene("buttonloser", ButtonChaseController(draw_bottom_layer=True, backwards_progress=True), SolidBackground(), ButtonRainbow(), Pulser()), Scene("wedges", NoOpCollaborationManager(), RotatingWedge(), GenericStatelessLauncher(wedge_factory, width=3, additive=False)), Scene("sinedots", NoOpCollaborationManager(), SolidBackground((100, 100, 100)), examples.SampleEffectLauncher(), FunctionFrameRotator( func=FunctionFrameRotator.no_op, start_offsets=5 * np.sin(np.linspace(0, 8 * np.pi, STATE.layout.rows)))),
class TonyTestEffect(Effect): """Always return red""" def next_frame(self, pixels, t, collaborative_state, osc_data): for ii, coord in enumerate(STATE.layout.pixels): pixels[ii] = (255, 0, 0) # a simple effect for the bottom of the ring in red class Background1(Effect): def next_frame(self, pixels, t, collaborative_state, osc_data): for ii, coord in enumerate(STATE.layout.pixels): self.gentle_glow(pixels, t, coord, ii) def gentle_glow(self, pixels, t, coord, ii): #if pixels[ii]: # return x, y, z = coord['point'] g = 0 b = 0 r = min(1, (1 - z) + color_utils.scaled_cos( x, offset=t / 5, period=2, minn=0, maxx=0.3)) pixels[ii] = (r * 255, g * 255, b * 255) __all__ = [ Scene("tonyscene1", NoOpCollaborationManager(), TonyTestEffect()), Scene("tonyscene2", NoOpCollaborationManager(), Background1()) ]
def next_frame(self, pixels, t, collaboration_state, osc_data): spark_ii = ((t - self.start_time) * 80) % STATE.layout.n_pixels for ii, c in [(int((spark_ii + x) % STATE.layout.n_pixels), 255 - x * 128 / self.spark_rad) for x in range(self.spark_rad)]: pixels[ii] = (c, c, c) class FailureEffect(Effect): """Force a failure after X frame""" def __init__(self, frames=30): self.frames = 30 def next_frame(self, pixels, now, collaboration_state, osc_data): self.frames -= 1 if self.frames < 0: raise Exception("Nobody expects me!") # FIXME : A little hacky - trying to avoid circular dependencies with generic_effects from generic_effects import NoOpCollaborationManager from generic_effects import SolidBackground __all__ = [ Scene("osc printer", NoOpCollaborationManager(), PrintOSC(), SolidBackground(30, 30, 30)), # Not a real effect. Just testing failures in effect code against the gulp server # Scene("failquick", NoOpCollaborationManager(), SolidBackground(0, 255, 0), FailureEffect()), Scene("bluewithdot", NoOpCollaborationManager(), SolidBackground(0, 255, 0), MovingDot()) ]
Effect.__init__(self) self.color = color self.bottom_row = bottom_row self.top_row_dict = { i: int(bottom_row + i * (max_row - bottom_row) / max_count) for i in range(1, max_count + 1) } self.current_level = int(bottom_row + (max_row - bottom_row) / max_count) self.target_row = self.current_level def next_frame(self, pixels, t, collaboration_state, osc_data): self.target_row = self.top_row_dict[collaboration_state["count"]] if self.target_row > self.current_level: self.current_level += 1 elif self.target_row < self.current_level: self.current_level -= 1 for ii in set( reduce(lambda a, b: a + b, [ STATE.layout.row[i] for i in range(self.bottom_row, self.current_level) ])): pixels[ii] = self.color __all__ = [ Scene("stoplight", StopTheLight(0, 2), SolidBackground((150, 150, 150)), CollaborationCountBasedBackground()) ]