def update_at_progress(self, progress, new_loop, loop_instance): if new_loop: if loop_instance % 4 == 0: if self.cm.modifiers[0]: c = random_color(luminosity="dark") self.kick_instrument.bg = c self.snare_instrument.bg = c else: self.kick_instrument.bg = color.BLACK self.snare_instrument.bg = color.BLACK if self.cm.modifiers[1]: self.kick_instrument.fg = random_color(luminosity="dark") self.snare_instrument.fg = random_color(luminosity="dark") elif self.cm.modifiers[2]: self.kick_instrument.fg = self.cm.chosen_colors[0] self.snare_instrument.fg = self.cm.chosen_colors[1] elif self.cm.modifiers[3]: self.kick_instrument.fg = color.RED self.snare_instrument.fg = color.BLUE else: self.kick_instrument.fg = color.PURPLE self.snare_instrument.fg = color.BLUE for track in self.tracks: track.update_at_progress(progress, new_loop, loop_instance)
def __init__(self, bird, hertz, cells): BirdLoop.__init__(self, bird, hertz, cells) self.front = geom.front_of_bird(bird) self.rear = geom.rear_of_bird(bird) self.front_clr = randomcolor.random_color(luminosity="light") self.rear_clr = randomcolor.random_color(luminosity="light")
def update_at_progress(self, progress, new_loop, loop_instance): if new_loop: if self.cm.modifiers[0]: self.foreground = random_color(luminosity="light") self.background = self.foreground.copy() self.background.h += 0.5 else: self.background = self.cm.chosen_colors[1] self.foreground = self.cm.chosen_colors[0] self.color_list = morph.transition_list(self.foreground, self.background, steps=16) self.clear() mode = self.step_mode(4) # _list defines what we loop over if mode == 3: _list = ice_geom.ICICLES elif mode == 2: _list = ice_geom.COLS elif mode == 1: _list = ice_geom.ROWS elif mode == 0: _list = ice_geom.SLICES # if mode == 4: # _list = sheep.ALL # elif mode == 3: # _list = [sheep.FACE, sheep.HEAD, sheep.EARS, sheep.THROAT, sheep.BREAST, sheep.SHOULDER, sheep.RACK, sheep.LOIN, sheep.LEG, sheep.BUTT, sheep.TAIL] # elif mode == 2: # _list = sheep.FRONT_SPIRAL # elif mode == 1: # _list = sheep.VSTRIPES # elif mode == 0: # _list = sheep.HSTRIPES # Because progress will never actually hit 1.0, this will always # produce a valid list index to_light = int(progress * len(_list)) for i in range(0, len(_list)): c = self.background if self.cm.modifiers[1]: c = color.BLACK if i <= to_light: x = i if len(_list) < len(self.color_list) / 2: x = i * 2 c_ix = x % len(self.color_list) if self.cm.modifiers[2] and (loop_instance % 2 == 0): c_ix = len(self.color_list) - 1 - c_ix c = self.color_list[c_ix] el = _list[i] self.ss.both.set_cell(el, c)
def __init__(self, sheep_sides): looping_show.LoopingShow.__init__(self, sheep_sides) self.foreground = random_color(luminosity="light") self.background = self.foreground.copy() self.background.h += 0.5 self.background.s += 0.5 self.mode = 0
def __init__(self, geometry): looping_show.LoopingShow.__init__(self, geometry) self.mode = 2 self.foreground = random_color(luminosity="light") self.background = self.foreground.copy() self.background.h += 0.5 self._list = []
def update_at_progress(self, progress, new_loop, loop_instance): # (loud, pitch) = self.audio.audio_input() if new_loop: #self.foreground = random_color(luminosity="light") self.foreground = random_color() self.background = self.foreground.copy() self.background.h += 0.5 self.color_list = morph.transition_list(self.foreground, self.background, steps=16) self.clear() # udpate mode every now and then if (loop_instance % 5 == 0): self.mode = (self.mode + 1) % 4 print "Changing mode to %s" % self.mode if self.mode == 0: self._list = [[x for x in range(model.numLEDs)]] elif self.mode ==1: self._list = model.HOR_RINGS_TOP_DOWN elif self.mode ==2: self._list = model.HOR_RINGS_MIDDLE_OUT elif self.mode ==3: self._list = model.HOR_RINGS_TOP_DOWN self._list.reverse() else: self._list = [[x for x in range(model.numLEDs)]] # Because progress will never actually hit 1.0, this will always # produce a valid list index to_light = int(progress * len(self._list)) for i in range(0, len(self._list)): c = self.background if i <= to_light: x = i if len(self._list) < len(self.color_list) / 2: x = i * 2 c_ix = x % len(self.color_list) #if self.cm.modifiers[2] and (loop_instance % 2 == 0): # c_ix = len(self.color_list) - 1 - c_ix c = self.color_list[c_ix] c.v = loud c = hsv_to_rgb(c.hsv) for i in self._list[i]: self.geometry.set_pixel(i, c) self.geometry.draw()
def update_at_progress(self, progress, new_loop, loop_instance): if self.cm.modifiers[0]: self.ss.party.set_cells(geom.ALL, geom.WHITE) else: self.ss.party.set_cells(geom.ALL, geom.DARK_RED) if new_loop: self.kick_instrument.fg = geom.PURPLE self.snare_instrument.fg = geom.BLUE if self.cm.modifiers[1]: self.kick_instrument.fg = self.cm.chosen_colors[0] self.snare_instrument.fg = self.cm.chosen_colors[1] if self.cm.modifiers[2]: self.kick_instrument.fg = random_color(luminosity="dark") self.snare_instrument.fg = random_color(luminosity="dark") for track in self.tracks: track.update_at_progress(progress, new_loop, loop_instance)
def update_at_progress(self, progress, new_loop, loop_instance): if new_loop: #if self.mode==0: self.foreground = random_color(luminosity="light") self.background = self.foreground.copy() self.background.h += 0.5 self.background.s += 0.2 ''' else: # TBD self.background = self.cm.chosen_colors[1] self.foreground = self.cm.chosen_colors[0] ''' self.color_list = morph.transition_list(self.foreground, self.background, steps=16) self.clear() #mode = self.step_mode(5) if self.mode == 1: _list = HOR_RINGS_TOP_DOWN elif self.mode == 0: _list = VERT_RINGS # Because progress will never actually hit 1.0, this will always # produce a valid list index to_light = int(progress * len(_list)) for i in range(0, len(_list)): c = self.background if i <= to_light: x = i if len(_list) < len(self.color_list) / 2: x = i * 2 c_ix = x % len(self.color_list) #if self.cm.modifiers[2] and (loop_instance % 2 == 0): if (loop_instance % 2 == 0): c_ix = len(self.color_list) - 1 - c_ix c = self.color_list[c_ix] el = _list[i] c = hsv_to_rgb(c.hsv) for i in el: self.geometry.set_pixel(i, c) self.geometry.draw()
def next_frame(self): while True: self.ss.both.clear() pan = self.cm.show_target[0] * math.pi tilt = self.cm.show_target[1] * math.pi color = self.cm.chosen_colors[0] if self.cm.modifiers[0]: color = random_color(luminosity="light"); FOV_10.map_value(self.ss, pan, tilt, color, symmetry=self.cm.modifiers[1]) # self.p.pan = self.cm.p_eye_pos[controls.PAN] # self.p.tilt = self.cm.p_eye_pos[controls.TILT] # self.b.pan = self.cm.b_eye_pos[controls.PAN] # self.b.tilt = self.cm.b_eye_pos[controls.TILT] yield 0.001
def next_frame(self): while True: self.ss.both.clear() pan = self.cm.show_target[0] * math.pi tilt = self.cm.show_target[1] * math.pi color = self.cm.chosen_colors[0] if self.cm.modifiers[0]: color = random_color(luminosity="light") FOV_10.map_value(self.ss, pan, tilt, color, symmetry=self.cm.modifiers[1]) # self.p.pan = self.cm.p_eye_pos[controls.PAN] # self.p.tilt = self.cm.p_eye_pos[controls.TILT] # self.b.pan = self.cm.b_eye_pos[controls.PAN] # self.b.tilt = self.cm.b_eye_pos[controls.TILT] yield 0.001
def update_at_progress(self, progress, new_loop, loop_instance): abs_pos = loop_instance + progress delta = abs_pos - self.last_abs_pos self.last_abs_pos = abs_pos if self.cm.modifiers[4]: # Do a sweeping was of color across the birds # Move the separater in the current direction using the current speed self.wash_pos += self.wash_speed * delta if self.wash_pos < 0: self.wash_pos = 0.0 if self.wash_pos > (geom.NUM_BIRDS - 1): self.wash_pos = float(geom.NUM_BIRDS - 1) wpi = int(self.wash_pos) for ix, bird in enumerate(geom.BIRDS): if ix == wpi: distance = self.wash_pos - wpi # hsv = tween.hsvLinear(self.wash_a, self.wash_b, distance) # clr = color.HSV(hsv[0], hsv[1], hsv[2]) # clr = self.wash_a.morph_towards(self.wash_b, distance) cutoff = distance * 30 for c_ix, c in enumerate(bird): if (c_ix < cutoff) or (60 - c_ix) < cutoff: self.ss.party.set_cell(c, self.wash_a) else: self.ss.party.set_cell(c, self.wash_b) elif ix < self.wash_pos: clr = self.wash_a self.ss.party.set_cells(bird, clr) else: clr = self.wash_b self.ss.party.set_cells(bird, clr) ############ # There is a chance of reversing the wash movement. Detect # quarter notes though q = math.floor(progress * 64.0) if q == 0.0 or q == 16.0 or q == 32.0 or q == 48.0: chance = 0.2 + 0.4 * ( (math.fabs(self.wash_speed) - self.min_speed) / (self.max_speed - self.min_speed)) if random.random() < chance: self.wash_speed = -self.wash_speed # If we reverse it, maybe we change the speed? if random.random() < 0.9: # Yes, change it. Increase or decrease equally if random.random() < 0.5: self.wash_speed = self.wash_speed / 1.3 else: self.wash_speed = self.wash_speed * 1.4 # Clamp the speed, respecting the sign if math.fabs(self.wash_speed) < self.min_speed: if self.wash_speed < 0.0: self.wash_speed = -self.min_speed else: self.wash_speed = self.min_speed if math.fabs(self.wash_speed) > self.max_speed: if self.wash_speed < 0.0: self.wash_speed = -self.max_speed else: self.wash_speed = self.max_speed #print "pos=%f speed=%f" % (self.wash_pos, self.wash_speed) # Enforce movement away from the ends if self.wash_pos == 0.0 and self.wash_speed < 0.0: self.wash_speed *= -1 if self.wash_pos == geom.NUM_BIRDS - 1 and self.wash_speed > 0.0: self.wash_speed *= -1 else: if self.cm.modifiers[0]: self.ss.party.set_cells(geom.ALL, geom.WHITE) else: self.ss.party.set_cells(geom.ALL, geom.DARK_RED) if new_loop: # self.wash_a = color.HSV(0.0, 1.0, 0.5) # self.wash_b = color.HSV(0.5, 0.3, 0.5) if self.cm.modifiers[1]: self.kick_instrument.fg = random_color(luminosity="dark") self.snare_instrument.fg = random_color(luminosity="dark") elif self.cm.modifiers[2]: self.kick_instrument.fg = self.cm.chosen_colors[0] self.snare_instrument.fg = self.cm.chosen_colors[1] self.wash_a = self.cm.chosen_colors[1] self.wash_b = self.cm.chosen_colors[0] elif self.cm.modifiers[3]: self.kick_instrument.fg = geom.RED self.snare_instrument.fg = geom.BLUE self.wash_a = geom.RED self.wash_b = geom.BLACK else: self.kick_instrument.fg = geom.PURPLE self.snare_instrument.fg = geom.BLUE self.wash_a = geom.ROSE self.wash_b = geom.QUARTZ for track in self.tracks: track.update_at_progress(progress, new_loop, loop_instance)
def update_at_progress(self, progress, new_loop, loop_instance): if new_loop: # The start of a loop has red at the left shoulder and # blue at the right flank if self.cm.modifiers[0]: self.redColor = random_color() self.redPos = self.redColor.pos self.blueColor = self.redColor.copy() self.blueColor.h = self.blueColor.h + 0.3 self.bluePos = self.blueColor.pos else: if self.cm.modifiers[1]: # Use the chosen colors self.redColor = self.cm.chosen_colors[0] self.blueColor = self.cm.chosen_colors[1] self.redPos = self.cm.chosen_colors_pos[0] self.bluePos = self.cm.chosen_colors_pos[1] else: # Just be red and blue cops self.redColor = color.RGB(255,30,30) self.blueColor = color.RGB(30,30,255); self.redPos = eyes.EYE_COLOR_RED self.bluePos = eyes.EYE_COLOR_BLUE # Panels # clear tham all if not self.cm.modifiers[2]: self.ss.both.clear() # mod 3 = reverse if not self.cm.modifiers[3]: if progress < 0.25: # Red moving down right flank redPan = tween.linear(FLANK_FORWARD_R, FLANK_REAR_R, (progress / 0.25)) elif progress < 0.5: redPan = tween.linear(FLANK_REAR_R, FLANK_REAR_L, (progress - 0.25) / 0.25) elif progress < 0.75: redPan = tween.linear(FLANK_REAR_L, FLANK_FORWARD_L, (progress - 0.50) / 0.25) else: redPan = tween.linear(FLANK_FORWARD_L, FLANK_FORWARD_R_WRAP, (progress - 0.75) / 0.25) else: if progress < 0.25: # Red moving from rear R flank to front p = progress / 0.25 redPan = tween.linear(FLANK_REAR_R, FLANK_FORWARD_R, p) elif progress < 0.5: p = (progress - 0.25) / 0.25 redPan = tween.linear(FLANK_FORWARD_R_WRAP, FLANK_FORWARD_L, p) elif progress < 0.75: p = (progress - 0.50) / 0.25 redPan = tween.linear(FLANK_FORWARD_L, FLANK_REAR_L, p) else: p = (progress - 0.75) / 0.25 redPan = tween.linear(FLANK_REAR_L, FLANK_REAR_R, p) if redPan < 0: redPan += (2*math.pi) elif redPan > (2*math.pi): redPan -= (2*math.pi) bluePan = redPan + math.pi if bluePan < 0: bluePan += (2*math.pi) elif bluePan > (2*math.pi): bluePan -= (2*math.pi) FOV_10.map_value(self.ss, redPan, 0, self.redColor) FOV_10.map_value(self.ss, bluePan, 0, self.blueColor) # Eyes self.pe.pan = -90 self.be.pan = -90; # mod 3 = reverse if not self.cm.modifiers[3]: if progress < 0.25: # Red moving down right flank # Eyes off, getting ready for blue to hit the left shoulder self.pe.effect = self.closed self.be.effect = self.closed self.pe.tilt = self.pe_tilt_start self.be.tilt = self.be_tilt_start self.pe.color_pos = self.bluePos self.be.color_pos = self.bluePos self.pe.dimmer = 0.0 elif progress < 0.5: # Tween from left to right self.pe.effect = None self.be.effect = None self.pe.tilt = tween.linear(self.pe_tilt_start, self.pe_tilt_end, (progress-0.25)/0.25) self.be.tilt = tween.linear(self.be_tilt_start, self.be_tilt_end, (progress-0.25)/0.25) self.pe.dimmer = 1.0 elif progress < 0.75: # Reset eyes getting ready for red to hit self.pe.effect = self.closed self.be.effect = self.closed self.pe.tilt = self.pe_tilt_start self.be.tilt = self.be_tilt_start self.pe.color_pos = self.redPos self.be.color_pos = self.redPos self.pe.dimmer = 0.0 else: # Tween from left to right self.pe.effect = None self.be.effect = None self.pe.tilt = tween.linear(self.pe_tilt_start, self.pe_tilt_end, (progress-0.75)/0.25) self.be.tilt = tween.linear(self.be_tilt_start, self.be_tilt_end, (progress-0.75)/0.25) self.pe.dimmer = 1.0 else: # Reverse direction if progress < 0.25: # Red moving from back of R flank to front # Reset eyes getting ready for red to hit self.pe.effect = self.closed self.be.effect = self.closed self.pe.tilt = self.pe_tilt_end self.be.tilt = self.be_tilt_end self.pe.color_pos = self.redPos self.be.color_pos = self.redPos self.pe.dimmer = 0.0 elif progress < 0.5: # Red moving across breast from R to L self.pe.effect = None self.be.effect = None p = (progress-0.25)/0.25 self.pe.tilt = tween.linear(self.pe_tilt_end, self.pe_tilt_start, p) self.be.tilt = tween.linear(self.be_tilt_end, self.be_tilt_start, p) self.pe.dimmer = 1.0 elif progress < 0.75: # Eyes off, getting ready for blue to hit the right shoulder self.pe.effect = self.closed self.be.effect = self.closed self.pe.tilt = self.pe_tilt_end self.be.tilt = self.be_tilt_end self.pe.color_pos = self.bluePos self.be.color_pos = self.bluePos self.pe.dimmer = 0.0 else: # Tween from right to left using blue self.pe.effect = None self.be.effect = None p = (progress-0.75)/0.25 self.pe.tilt = tween.linear(self.pe_tilt_end, self.pe_tilt_start, p) self.be.tilt = tween.linear(self.be_tilt_end, self.be_tilt_start, p) self.pe.dimmer = 1.0
def __init__(self, sheep_sides): looping_show.LoopingShow.__init__(self, sheep_sides) self.foreground = random_color(luminosity="light") self.background = self.foreground.copy() self.background.h += 0.5
def update_at_progress(self, progress, new_loop, loop_instance): if new_loop: if self.cm.modifiers[0]: self.foreground = self.cm.chosen_colors[0] self.background = self.cm.chosen_colors[1] else: if self.cm.modifiers[1] or (random.randrange(10) > 7) or ( not hasattr(self, "foreground")): # Definitely need a new color if random.randrange(10) > 7: # Also reverse direction self.cm.set_modifier(2, not self.cm.modifiers[2]) if self.cm.modifiers[4] or (not hasattr( self, "foreground")): # Two totally new colors self.foreground = random_color(luminosity="dark") self.background = self.foreground.copy() if self.background.h < 0.5: self.background.h += 0.5 else: self.background.h -= 0.5 else: # Keep old foreground self.background = self.foreground self.foreground = random_color(luminosity="dark") for ring in geom.RINGS: el_size = 1.0 / len(ring) # Debug ring 3 only # debug = el_size < 0.4 # if debug: # print for ix, el in enumerate(ring): partial = 1.0 el_start = (ix * el_size) + 0.25 if el_start >= 1.0: el_start -= 1.0 el_end = ((ix + 1) * el_size) + 0.25 if el_end > 1.0: el_end -= 1.0 v = 0.0 p = progress backwards = self.cm.modifiers[2] if backwards: p = 1.0 - progress mode = self.step_mode(2) if mode == 0: # A single edge that sweeps from 0 to full if p >= el_end: v = 1.0 elif p > el_start: v = (p - el_start) / el_size # else v stays at 0 elif mode == 1: # A 0.25 segment v = self.calcV(el_start, el_end, p, 0.25, debug=False) # if debug: # print " %0.4f" % v clr = color.HSV( *tween.hsvLinear(self.background, self.foreground, v)) self.ss.party.set_cell(el, clr)
def control_modifiers_changed(self): if self.cm.modifiers[1]: # Only do randoms on change of the modifier self.wash_a = random_color(luminosity="dark") self.wash_b = random_color(luminosity="dark")
def update_at_progress(self, progress, new_loop, loop_instance): if new_loop: if not self.cm.modifiers[0]: self.foreground = random_color(luminosity="dark") self.background = self.foreground.copy() self.background.h += 0.5 else: self.background = self.cm.chosen_colors[1] self.foreground = self.cm.chosen_colors[0] if self.cm.modifiers[2]: t = self.foreground self.foreground = self.background self.background = t # self.color_list = morph.transition_list(self.foreground, self.background, steps=16) self.clear() mode = self.step_mode(5) # _list defines what we loop over if mode == 4: _list = geom.SPIRAL elif mode == 3: _list = geom.QUADRANTS elif mode == 2: _list = geom.RINGS elif mode == 1: _list = geom.VSTRIPES elif mode == 0: _list = geom.HSTRIPES # if mode == 4: # _list = sheep.ALL # elif mode == 3: # _list = [sheep.FACE, sheep.HEAD, sheep.EARS, sheep.THROAT, sheep.BREAST, sheep.SHOULDER, sheep.RACK, sheep.LOIN, sheep.LEG, sheep.BUTT, sheep.TAIL] # elif mode == 2: # _list = sheep.FRONT_SPIRAL # elif mode == 1: # _list = sheep.VSTRIPES # elif mode == 0: # _list = sheep.HSTRIPES # Make sure it always has an even count if len(_list) % 2 == 1: _list = _list + [[]] # Because progress will never actually hit 1.0, this will always # produce a valid list index to_light = int(progress * len(_list)) for i in range(0, len(_list)): # Determine a background c = self.background if self.cm.modifiers[1]: c = geom.DARK_RED # But possibly make it a lit color if i <= to_light: c = self.foreground # Don't like all this color morph stuff... # x = i # if len(_list) < len(self.color_list) / 2: # x = i * 2 # c_ix = x % len(self.color_list) # if self.cm.modifiers[2] and (loop_instance % 2 == 0): # c_ix = len(self.color_list) - 1 - c_ix # c = self.color_list[c_ix] el = _list[i] if self.cm.modifiers[4]: el = _list[len(_list) - 1 - i] self.ss.both.set_cell(el, c)