Source code for BiblioPixelAnimations.strip.ColorFade

from bibliopixel.animation.strip import Strip
from bibliopixel.colors import COLORS
from bibliopixel.colors.arithmetic import color_scale


[docs]class ColorFade(Strip): """Fill the dots progressively along the strip.""" COLOR_DEFAULTS = ('colors', [COLORS.Red]),
[docs] def wave_range(self, start, peak, step): main = [i for i in range(start, peak + 1, step)] return main + [i for i in reversed(main[0:len(main) - 1])]
def __init__(self, layout, step=5, start=0, end=-1, **kwds): super().__init__(layout, start, end, **kwds) self._levels = self.wave_range(30, 255, step) self._level_count = len(self._levels)
[docs] def pre_run(self): self._step = 0
[docs] def step(self, amt=1): c_index, l_index = divmod(self._step, self._level_count) color = self.palette(c_index) color = color_scale(color, self._levels[l_index]) self.layout.fill(color, self._start, self._end) self._step += amt