Ejemplo n.º 1
0
def get_color(i, n=6):
    # at the hard level, there are two greens that look nearly identical
    # but I wasn't able to find alternative color choices that are any better
    # I tried the 10 color qualitative colormap from
    # http://colorbrewer2.org/#type=qualitative&scheme=Paired&n=10
    # but the light colors all looked the same on the simulator
    i = i % n
    return color_utils.hsv2rgb((i * 255 / n, 255, 255))
Ejemplo n.º 2
0
    def set_pixels(self, pixels):

        hsv = np.full((self.X_MAX, self.Y_MAX, 3), 0xFF, dtype=np.uint8)
        hsv[:, :, self.wave_type] = self.pixels[2] / 0xFFFF * 0xFF
        if self.wave_type == self.VALUE:
            hsv[:, :, 1] = 0
        if self.darken_mids:
            hsv[:, :,
                2] = np.abs(self.pixels[2] - (0xFFFF >> 1)) / 0xFFFF * 0xFF

        rgb = color_utils.hsv2rgb(hsv)
        pixels[:self.X_MAX, :self.Y_MAX] = rgb

        self.pixels.pop(0)
Ejemplo n.º 3
0
    def __call__(self, now, **kwargs):
        hue = self.hue.update(now)

        primary = int(self.size / 2 * self.frac)
        compliment = self.size / 2 - primary
        pixels = np.zeros((self.size / 2, 3), np.uint8)

        pixels[:primary, 0] = hue
        steps = color_utils.color_correct(
            np.linspace(255, self.min_gray, primary, dtype=np.uint8))
        pixels[:primary, 1] = steps
        pixels[:primary, 2] = steps

        pixels[primary:, 0] = hue + 128
        steps = color_utils.color_correct(
            np.linspace(self.min_gray, 255, compliment, dtype=np.uint8))
        pixels[primary:, 1] = steps
        pixels[primary:, 2] = steps
        pixels = color_utils.hsv2rgb(pixels)
        return np.concatenate((pixels, pixels[::-1]))
Ejemplo n.º 4
0
def fader_value_to_color(n):
    return color_utils.hsv2rgb(np.array((n * 255 / 100, 255, 255)))
Ejemplo n.º 5
0
 def next_frame(self, now, pixels):
     if now > self.switch:
         self._next_frame()
         self.switch = now + .15
     pixels[:] = color_utils.hsv2rgb(self.my_pixels)
Ejemplo n.º 6
0
 def colors(self, now):
     return color_utils.hsv2rgb(
         [ct.update(now) for ct in self.color_transitions])
Ejemplo n.º 7
0
 def __call__(self, now):
     self.update_color()
     row = np.zeros((self.layout.columns, 3), np.uint8)
     row[10, :] = color_utils.hsv2rgb(self.color)
     return self.rotate(row, now)
Ejemplo n.º 8
0
 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)
Ejemplo n.º 9
0
 def color(self):
     hue = (self.color_offset + min(255, self.n_hits // 4)) % 256
     return color_utils.hsv2rgb((hue, 255, 255))