I am almost there, just need a little more help Please

I started with the code from Edgeburst, and with some help, I got the exact pattern I was looking for. Now I just need help with color. I am using “hue” for the colors of pattern, but I need White where I currently have blue (hue =.66;). I am assuming that I will need to call it by RGB instead of hue, but I’m so new to Pixelblaze that I’m not sure how to get the color white. If I can be nudged in the right direction I would definitely appreciate it!

To be clear, I want the color White to replace my hue = .66; in my if statement below.

Also, if someone can tell me how to properly put code into the post I’d appreciate it :smile:


export function beforeRender(delta) {
t1 = triangle(time(.045)) // Mirror time (bounce)

export function render(index) {
pct = index / pixelCount
edge = clamp(triangle(pct) + t1 * 4 - 2, 0, 1) // Mirror space

// h = edge * edge - .2 // Expand violets

v = triangle(edge) // Doubles the frequency

if (pct > .45 && pct < .55){
hue = .66;

(pct > 0.55) {
hue = 0.33;

if(pct < .45 ){
hue = 0.0;


1 Like

You just need to change the saturation value (s) when you call hsv(). If s = 1 the colour is fully saturated. If you make it 0 then you’d get white at whatever brightness is set by the v parameter. If you make s equal something like 0.3 to 0.7, you will get more diluted colours.

Start by trying different values in place of the 1 in your hsv() call. The you can make it conditional as you need, either when you set the hue parameter or separately.


Thank you very much!! I tried modifying the saturation for the call after my if statements (before I posted here), but that made the whole strip white. From your suggestion, I made the hsv call from within each of the if statements, and that did the trick!

I very much appreciate your help!


There are many ways to handle this. Often it can be less confusing when you come back to the code many months later only to have one call, especially if you are adding further capabilities. An alternative is to pass a saturation parameter (sat?) as you did with hue in your above code. However, it’s also important not to get too hung up on coding style and to have fun while doing it. I am glad that I could help.

If you have not yet done so, I recommend downloading many of the example patterns that are available at https://electromage.com/patterns

I have learned a lot from some of these before then tweaking them to suit my own requirements.

1 Like