def update_at_progress(self, progress, new_loop, loop_instance): if self.mode == 0: # Color striped from top to bottom by slices v_range = tween.easeInQuad(0.1, 0.98, (self.cm.brightness + 1.0)/2.0) per_slice = v_range / len(self.range) for idx, sl in enumerate(self.range): hue = progress - (idx * per_slice) + self.offsets[0] while hue > 1.0: hue -= 1.0 while hue < 0.0: hue += 1.0 hsv = (hue, 1.0, 1.0) rgbTuple = color2.hsvRYB_to_rgb(hsv) rgbTuple = (int(rgbTuple[0]), int(rgbTuple[1]), int(rgbTuple[2])) for i in sl: self.geometry.set_pixel(i, rgbTuple) self.geometry.draw() elif self.mode == 1: # Each bird gets a unique color based on it's offset for idx,bird in enumerate(self.range): hue = progress + self.offsets[idx] if hue > 1.0: hue -= 1.0 hsv = (hue, 1.0, 1.0) rgbTuple = color2.hsvRYB_to_rgb(hsv) rgbTuple = (int(rgbTuple[0]), int(rgbTuple[1]), int(rgbTuple[2])) for i in bird: self.geometry.set_pixel(i, rgbTuple) self.geometry.draw() else: # Everything the same color hsv = (progress + self.offsets[0], 1.0, 1.0) rgbTuple = color2.hsvRYB_to_rgb(hsv) rgbTuple = (int(rgbTuple[0]), int(rgbTuple[1]), int(rgbTuple[2])) for i in range(self.geometry.get_nof_pixels()): self.geometry.set_pixel(i, rgbTuple) self.geometry.draw()
def rainbow_(progress, step, brightness, numSlices=18): # step chooses which color of the rainbow # progress is the blender parameter from 0 to 1 v_range = tween.easeInQuad(0.1, 0.98, (brightness + 1.0)/2.0) per_slice = v_range / numSlices hue = progress - (step % numSlices * per_slice) while hue > 1.0: hue -= 1.0 while hue < 0.0: hue += 1.0 hsv = (hue, 1.0, 1.0) rgbTuple = color2.hsvRYB_to_rgb(hsv) return (int(rgbTuple[0]), int(rgbTuple[1]), int(rgbTuple[2]))
def update_at_progress(self, progress, new_loop, loop_instance): mode = self.step_mode(3) if mode == 0: # Color striped from top to bottom by slices v_range = tween.easeInQuad(0.1, 0.98, (self.cm.intensified + 1.0) / 2.0) #v_range = 0.1 + ((self.cm.intensified + 1.0)/2.0 * 0.89) # how much of the hue cycle to spread across top to bottom per_slice = v_range / len(ice_geom.SLICES) for idx, sl in enumerate(ice_geom.SLICES): hue = progress - (idx * per_slice) + self.offsets[0] if hue > 1.0: hue -= 1.0 if hue < 0.0: hue += 1.0 hsv = (hue, 1.0, 1.0) rgbTuple = color.hsvRYB_to_rgb(hsv) rgb = color.RGB(*rgbTuple) self.ss.party.set_cells(sl, rgb) elif mode == 1: # Each icicle gets a unique color based on it's offset for idx, icicle in enumerate(ice_geom.ICICLES): hue = progress + self.offsets[idx] if hue > 1.0: hue -= 1.0 hsv = (hue, 1.0, 1.0) rgbTuple = color.hsvRYB_to_rgb(hsv) rgb = color.RGB(*rgbTuple) self.ss.party.set_cells(icicle, rgb) else: # Everything the same color hsv = (progress + self.offsets[0], 1.0, 1.0) rgbTuple = color.hsvRYB_to_rgb(hsv) rgb = color.RGB(*rgbTuple) self.ss.party.set_all_cells(rgb)
def update_at_progress(self, progress, new_loop, loop_instance): mode = self.step_mode(3) if mode == 0: # Color striped from top to bottom by slices v_range = tween.easeInQuad(0.1, 0.98, (self.cm.intensified + 1.0)/2.0) #v_range = 0.1 + ((self.cm.intensified + 1.0)/2.0 * 0.89) # how much of the hue cycle to spread across top to bottom per_slice = v_range / len(ice_geom.SLICES) for idx, sl in enumerate(ice_geom.SLICES): hue = progress - (idx * per_slice) + self.offsets[0] if hue > 1.0: hue -= 1.0 if hue < 0.0: hue += 1.0 hsv = (hue, 1.0, 1.0) rgbTuple = color.hsvRYB_to_rgb(hsv) rgb = color.RGB(*rgbTuple) self.ss.party.set_cells(sl, rgb) elif mode == 1: # Each icicle gets a unique color based on it's offset for idx,icicle in enumerate(ice_geom.ICICLES): hue = progress + self.offsets[idx] if hue > 1.0: hue -= 1.0 hsv = (hue, 1.0, 1.0) rgbTuple = color.hsvRYB_to_rgb(hsv) rgb = color.RGB(*rgbTuple) self.ss.party.set_cells(icicle, rgb) else: # Everything the same color hsv = (progress + self.offsets[0], 1.0, 1.0) rgbTuple = color.hsvRYB_to_rgb(hsv) rgb = color.RGB(*rgbTuple) self.ss.party.set_all_cells(rgb)
def update_at_progress(self, progress, new_loop, loop_instance): mode = self.step_mode(4) if mode == 0: # Color striped from top to bottom by slices v_range = tween.easeInQuad(0.1, 0.98, (self.cm.intensified + 1.0)/2.0) #v_range = 0.1 + ((self.cm.intensified + 1.0)/2.0 * 0.89) # how much of the hue cycle to spread across top to bottom per_slice = v_range / len(geom.ICICLES) for idx, sl in enumerate(geom.ICICLES): hue = progress - (idx * per_slice) + self.offsets[0] while hue > 1.0: hue -= 1.0 while hue < 0.0: hue += 1.0 hsv = (hue, 1.0, 1.0) rgbTuple = color.hsvRYB_to_rgb(hsv) # Now factor in an intensity # v = 0.2 + (((self.cm.intensified + 1.0) / 2.0) * 0.8) # rgb = color.RGB(*rgbTuple) # rgb = color.RGB(rgbTuple[0] * v, rgbTuple[1] * v, rgbTuple[2] * v) self.ss.party.set_cells(sl, self.finalFromRGB(rgbTuple)) elif mode == 1: # Each icicle gets a unique color based on it's offset for idx,icicle in enumerate(geom.ICICLES): hue = progress + self.offsets[idx] if hue > 1.0: hue -= 1.0 hsv = (hue, 1.0, 1.0) rgbTuple = color.hsvRYB_to_rgb(hsv) # rgb = color.RGB(*rgbTuple) self.ss.party.set_cells(icicle, self.finalFromRGB(rgbTuple)) elif mode == 2: # Set colors element by element in each ring based on radial for ring_ix, ring in enumerate(geom.RINGS): step = 1.0 / len(ring) for tube_ix, tube in enumerate(ring): hue = progress + self.offsets[0] + tube_ix * step while hue > 1.0: hue -= 1.0 while hue < 0.0: hue += 1.0 hsv = (hue, 1.0, 1.0) rgbTuple = color.hsvRYB_to_rgb(hsv) # rgb = color.RGB(*rgbTuple) self.ss.party.set_cell(tube, self.finalFromRGB(rgbTuple)) else: # Everything the same color hsv = (progress + self.offsets[0], 1.0, 1.0) rgbTuple = color.hsvRYB_to_rgb(hsv) self.ss.party.set_all_cells(self.finalFromRGB(rgbTuple))