def pixel_color(self, t, ii): """Compute the color of a given pixel. t: time in seconds since the program started. ii: which pixel this is, starting at 0 coord: the (x, y, z) position of the pixel as a tuple n_pixels: the total number of pixels Returns an (r, g, b) tuple in the range 0-255 """ x, y, z = self._layout[ii] w1 = color_utils.cos(t, period=17) w2 = color_utils.cos(t, offset=30, period=23) red = (1.0, 0.0, 0.0) orange = (0.5, 0.25, 0.0) channel_1 = color_utils.scale( red, color_utils.cos(x + y, offset=-w2, period=3, minn=0.1, maxx=0.5)) channel_2 = color_utils.scale( orange, color_utils.cos(x + y, offset=w1, period=5, minn=0.1, maxx=0.5)) r, g, b = (0, 0, 0) r, g, b = color_utils.v_add([r, g, b], channel_1) r, g, b = color_utils.v_add([r, g, b], channel_2) return (r, g, b)
def pixel_color(self, t, ii): """Compute the color of a given pixel. t: time in seconds since the program started. ii: which pixel this is, starting at 0 coord: the (x, y, z) position of the pixel as a tuple n_pixels: the total number of pixels Returns an (r, g, b) tuple in the range 0-255 """ # x, y, z = self._layout[ii] r = g = b = 0 blinker = color_utils.cos(ii / 100, offset=t / 8, period=1, minn=0.0, maxx=1.0) if blinker < 0.5: return (0, 0, 0) m = int(ii / self.grouping) % self.spacing if int(t) % 4 > 1: m = (m + self.spacing // 2) % self.spacing return self.lookup[m] return (r, g, b)
def pixel_color(self, t, ii): """Compute the color of a given pixel. t: time in seconds since the program started. ii: which pixel this is, starting at 0 coord: the (x, y, z) position of the pixel as a tuple n_pixels: the total number of pixels Returns an (r, g, b) tuple in the range 0-255 """ # make moving stripes for x, y, and z x, y, z = self._layout[ii] r = color_utils.cos(x + y + z, offset=t / 4, period=1, minn=0, maxx=0.7) g = color_utils.cos(x + y + z, offset=t / 3, period=1, minn=0, maxx=0.7) b = color_utils.cos(x + y + z, offset=t / 5, period=1, minn=0, maxx=0.7) r, g, b = color_utils.contrast((r, g, b), 0.5, 2) # make a moving white dot showing the order of the pixels in the layout file spark_ii = (t * 80) % self.n_pixels() spark_rad = 8 spark_val = max( 0, (spark_rad - color_utils.mod_dist(ii, spark_ii, self.n_pixels())) / spark_rad, ) spark_val = min(1, spark_val * 2) r += spark_val g += spark_val b += spark_val return (r, g, b)
def pixel_color(self, t, ii): """Compute the color of a given pixel. t: time in seconds since the program started. ii: which pixel this is, starting at 0 coord: the (x, y, z) position of the pixel as a tuple n_pixels: the total number of pixels Returns an (r, g, b) tuple in the range 0-255 """ x, y, z = self._layout[ii] w1 = color_utils.cos(t, period=17) w2 = color_utils.cos(t, offset=30, period=23) # r = g = b = color_utils.cos(x+y, offset=w1, period=1, minn=0.0, maxx=0.4) # (r,g,b) = color_utils.contrast((r,g,b), 0.5, 4) r = 0 b = color_utils.cos(x + y, offset=w1, period=5, minn=0.1, maxx=0.5) g = color_utils.cos(x + y, offset=w2, period=3, minn=0.2, maxx=0.4) return (r, g, b)
def pixel_color(self, t, ii): """Compute the color of a given pixel. t: time in seconds since the program started. ii: which pixel this is, starting at 0 coord: the (x, y, z) position of the pixel as a tuple n_pixels: the total number of pixels Returns an (r, g, b) tuple in the range 0-255 """ x, y, z = self._layout[ii] w1 = color_utils.cos(t, period=17) w2 = color_utils.cos(t, offset=30, period=23) darkblue = (0.0, 0.0, 0.0) # blue = (0.0, 0.0, 1.0) magenta = (1.0, 0.0, 1.0) cyan = (0.0, 0.7, 0.7) # channel_1 = color_utils.scale( # blue, color_utils.cos(x + y, offset=-w2, period=3, minn=0.1, maxx=0.5) # ) channel_2 = color_utils.scale( magenta, color_utils.cos(x + y, offset=w1, period=5, minn=0.1, maxx=0.5)) channel_3 = color_utils.scale( cyan, color_utils.cos(x + y, offset=w2, period=7, minn=0.2, maxx=0.4)) r, g, b = darkblue # r,g,b = color_utils.v_add([r,g,b], channel_1) r, g, b = color_utils.v_add([r, g, b], channel_2) r, g, b = color_utils.v_add([r, g, b], channel_3) return (r, g, b)
def pixel_color(self, t, ii): """Compute the color of a given pixel. t: time in seconds since the program started. ii: which pixel this is, starting at 0 coord: the (x, y, z) position of the pixel as a tuple Returns an (r, g, b) tuple in the range 0-255 """ # # random persistant color per pixel # r = color_utils.remap(random_values[(ii+0)%n_pixels], 0, 1, 0.2, 1) # g = color_utils.remap(random_values[(ii+3)%n_pixels], 0, 1, 0.2, 1) # b = color_utils.remap(random_values[(ii+6)%n_pixels], 0, 1, 0.2, 1) # random assortment of a few colors per pixel: pink, cyan, white if self.__random_values[ii] < 0.5: r, g, b = (1, 0.3, 0.8) elif self.__random_values[ii] < 0.85: r, g, b = (0.4, 0.7, 1) else: r, g, b = (2, 0.6, 1.6) # twinkle occasional LEDs twinkle = (self.__random_values[ii] * 7 + t * self.__twinkle_speed) % 1 twinkle = abs(twinkle * 2 - 1) twinkle = color_utils.remap(twinkle, 0, 1, -1 / self.__twinkle_density, 1.1) twinkle = color_utils.clamp(twinkle, -0.5, 1.1) twinkle **= 5 twinkle *= color_utils.cos(t - ii / self.n_pixels(), offset=0, period=7, minn=0.1, maxx=1.0)**20 twinkle = color_utils.clamp(twinkle, -0.3, 1) r *= twinkle g *= twinkle b *= twinkle return (r, g, b)
def pixel_color(self, t, ii): """Compute the color of a given pixel. t: time in seconds since the program started. ii: which pixel this is, starting at 0 coord: the (x, y, z) position of the pixel as a tuple n_pixels: the total number of pixels Returns an (r, g, b) tuple in the range 0-255 """ x, y, z = self._layout[ii] block = int(ii / self.block_size) period = (((block + 1) * 51) % 37) + 1 hue = color_utils.cos(t / 25 + block, offset=0, period=period, minn=0.0, maxx=1.0) r, g, b = colorsys.hsv_to_rgb(hue, 1.0, 1.0) return (r, g, b)