White only patterns?

As noted in some posts I have read, it’s hard to get past the lack of pallettes in this otherwise far superior language and platform.

I really love how flexible Pixelblaze is, but it’s very “rainbow vomit” by default…I have made sure to buy rgbww strips in the hope of being somewhat tasteful in my applications, but I am really struggling to get where I want to be via my “template and redo” approach.


A couple of things come to mind.

First, if you want to modify an existing pattern that uses hsv() to set color, it’s very easy to constrain hue to a range. This works especially well on “rainbow” patterns because they use the full range of hue values. The general formula is:

hue(startcolor+hueRange * (old pattern color), sat, bri);

So for example, to constrain the color of any rainbow pattern to a blue/green color set, you could use

hue(0.6 + 0.06667 * (old color calculation), old saturation, old brightness);

If you want to play with starting color and range, set up a color picker control to pick your initial hue, and a slider control to change the range.

You can also move colors away from the LED rainbow by subtracting just a little from the saturation. Even subtracting 0.2 or 0.3 from a fully saturated color adds quite a lot of white and makes for a different look.

Also, current Pixelblaze firmware actually does support per-pattern RGB palettes. They’re not widely used yet. But you can build a custom palette of RGB colors, use setPalette to activate it, and then call paint() instead of rgb() or hsv() in your render() functon to interpolate a palette color for the pixel.

(Here’s the documentation from the PB editor page – it’s a longish scroll down the page and easy to miss.)


Sets the palette to a gradient based on an array of positions and RGB values. For example, this fades from black to magenta to cyan:

var rgbGradient = [
  0,    0, 0, 0, //position start, rgb(0,0,0)
  0.75, 1, 0, 1, //position 75%, rgb(1,0,1)
  1,    0, 1, 1  // position end, rgb(0,1,1)

paint(value, [brightness=1])

Sets the current pixel to a color based on the value’s position in the current palette. Value “wraps” between 0.0 and 1.0. Negative values wrap backwards. Optionally brightness can be specified.


This is really helpful! Thanks so much.