def __call__(self, now): v = np.sin(np.pi * now) c = color_utils.remap(v, -1, 1, 0, 31) color_a = (BRIGHTNESS_A[int(c)], 0, 0) color_b = (0, BRIGHTNESS_B[int(c)], 0) color_a = (BRIGHTNESS_A[self.idx], 0, 0) color_b = (0, BRIGHTNESS_B[self.idx], 0) self.idx += self.delta if self.idx == 0 or self.idx == 31: self.delta *= -1 n = int(self.layout.columns / 4) return np.array([color_a] * n + [(0, 0, 0)] * (n + 1) + [color_b] * n + [(0, 0, 0)] * (n + 1))
def next_frame(self, now, pixels): # This has a jitter to it at the edges. I think its a result of # the way I am mapping speed to pxs. for row, (color, width) in enumerate(zip(self.color, self.width)): width = int(width) if (2 * width) + 1 > self.layout.columns: pixels[row, :] = color continue start = (self.center - width) % self.layout.columns end = (self.center + width + 1) % self.layout.columns if start < end: pixels[row, start:end] = color else: pixels[row, start:] = color pixels[row, :end] = color px = self.speed(now) if px > 0: self.color[px:] = self.color[:-px] self.color[:px] = (self.clr, 0, 0) self.clr = color_utils.remap(np.sin(2 * np.pi * time.time()), -1, 1, 0, 255) self.width[px:] = self.width[:-px] + .25 self.width[px] = 1
def __call__(self, now): v = np.sin(np.pi * now) val = color_utils.remap(v, -1, 1, 0, 255) color = color_utils.hsv2rgb((0, 255, val)) color = (val, 0, 0) return np.array([color] * self.layout.columns)
def new_color(self, now): # need this to follow a linear brightness return color_utils.color_correct( int(color_utils.remap(np.sin(4 * np.pi * now), -1, 1, 0, 255)))