def spatial_stripes(t, coord, ii, n_pixels): """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 = coord r = color_utils.scaled_cos(x, offset=t / 4, period=1, minn=0, maxx=0.7) g = color_utils.scaled_cos(y, offset=t / 4, period=1, minn=0, maxx=0.7) b = color_utils.scaled_cos(z, offset=t / 4, 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) % n_pixels spark_rad = 8 spark_val = max( 0, (spark_rad - color_utils.mod_dist(ii, spark_ii, n_pixels)) / spark_rad) spark_val = min(1, spark_val * 2) r += spark_val g += spark_val b += spark_val # apply gamma curve # only do this on live leds, not in the simulator #r, g, b = color_utils.gamma((r, g, b), 2.2) return (r * 256, g * 256, b * 256)
def gentle_glow(self, t, coord, ii, n_pixels): x, y, z = coord g = 0 b = 0 r = min(1, (1 - z) + color_utils.scaled_cos(x, offset=t / 5, period=2, minn=0, maxx=0.3)) #For some reason, this is zeroing out some pixels. Needs debugging return (r*256, g*256, b*256)
def spatial_stripes(self, t, coord, ii, n_pixels): """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 = coord["point"] r = color_utils.scaled_cos(x, offset=t / 4, period=1, minn=0, maxx=0.7) g = color_utils.scaled_cos(y, offset=t / 4, period=1, minn=0, maxx=0.7) b = color_utils.scaled_cos(z, offset=t / 4, period=1, minn=0, maxx=0.7) r, g, b = color_utils.contrast((r, g, b), 0.5, 2) return (r*256, g*256, b*256)
def wheelSpinEffect(system, state): for pixel in system: x, y, z, theta, r, xr, yr = pixel['coord'] pos = state.wheel_position intensity = color_utils.scaled_cos(theta, offset=pos / (2 * pi), period=pi / 4, minn=-1, maxx=1) #color1 = (0.1, 1.0, 0.3) #color2 = (0.1, 0.4, 0.9) #color = scaleTuple(color1, intensity) if intensity > 0 else scaleTuple(color2, abs(intensity)) #system.set_pixel_rgb(pixel, color) colorA = color_utils.scaled_cos(state.time / 288, offset=0, minn=0, maxx=1) colorB = 1 - colorA color = colorA if intensity > 0 else colorB system.set_pixel(pixel, color, abs(intensity))
def miami_color(t, pixel, random_values, accum): # hue-restricted, faster version of miami.py from OPC samples # make moving stripes for x, y, and z x, y, z, theta, r, xr, yr = pixel['coord'] y += color_utils.scaled_cos(x - 0.2*z, offset=0, period=1, minn=0, maxx=0.6) z += color_utils.scaled_cos(x, offset=0, period=1, minn=0, maxx=0.3) x += color_utils.scaled_cos(y - z, offset=0, period=1.5, minn=0, maxx=0.2) # make x, y, z -> r, g, b sine waves r = color_utils.scaled_cos(y, offset=t / 16, period=2.5, minn=0, maxx=1) g = color_utils.scaled_cos(z, offset=t / 16, period=2.5, minn=0, maxx=1) b = color_utils.scaled_cos(-x, offset=t / 16, period=2.5, minn=0, maxx=1) r, g, b = color_utils.contrast((r, g, b), 0.5, 1.4) clampdown = (r + g + b)/2 clampdown = color_utils.remap(clampdown, 0.4, 0.5, 0, 1) clampdown = color_utils.clamp(clampdown, 0, 1) clampdown *= 0.8 r *= clampdown g *= clampdown b *= clampdown g = g * 0.1 + 0.8 * (b + 0.2 * r) / 2 return (r, g, b)
def miami_color(t, pixel, random_values, accum): # hue-restricted, faster version of miami.py from OPC samples # make moving stripes for x, y, and z x, y, z, theta, r, xr, yr = pixel['coord'] y += color_utils.scaled_cos(x - 0.2 * z, offset=0, period=1, minn=0, maxx=0.6) z += color_utils.scaled_cos(x, offset=0, period=1, minn=0, maxx=0.3) x += color_utils.scaled_cos(y - z, offset=0, period=1.5, minn=0, maxx=0.2) # make x, y, z -> r, g, b sine waves r = color_utils.scaled_cos(y, offset=t / 16, period=2.5, minn=0, maxx=1) g = color_utils.scaled_cos(z, offset=t / 16, period=2.5, minn=0, maxx=1) b = color_utils.scaled_cos(-x, offset=t / 16, period=2.5, minn=0, maxx=1) r, g, b = color_utils.contrast((r, g, b), 0.5, 1.4) clampdown = (r + g + b) / 2 clampdown = color_utils.remap(clampdown, 0.4, 0.5, 0, 1) clampdown = color_utils.clamp(clampdown, 0, 1) clampdown *= 0.8 r *= clampdown g *= clampdown b *= clampdown g = g * 0.1 + 0.8 * (b + 0.2 * r) / 2 return (r, g, b)