Saved Patterns w/ Detailed Comments


Please send the link where I can download Jeff’s detailed comments for PB saved patterns.


Hi Kamehana!

If you received a v3 Pixelbalze, the comments are in the pre-loaded patterns that come on the shipped board.

If you have a v2, have a look at (subdirs contain js & importable epes).

All code in that repo is compatible with both hardware (v2 and v3s). As we’ve said elsewhere, we’re working towards a system that will always have the most updated patterns in the pattern library, and when that happens I’ll delete the repo linked above.

Let me know if I can help in any other way!



Thanks Jeff!

Much appreciated.


1 Like


Not sure if this is the place to ask this. However, I do have an additional question.
In the following Intro into PB code:

export function render(index) {
red = green = blue = 0
leadPosition = time(0.08) * pixelCount
red = abs(leadPosition - index - 0) < 1
green = abs(leadPosition - index - 4) < 1
blue = abs(leadPosition - index - 8) < 1
rgb(red, green, blue)

Why does taking the absolute value of the following expression: (leadPosition - index - 0) cause the red LED to turn on and off in sequence? It’s a very cool effect but I am trying to understand the thinking behind the construction.


1 Like

Sure. Subtraction gives the distance between two points, but it’s signed. Abs() will yield the distance as a positive number.

The “< 1” means “It’s true if the distance is less than one pixel (in either direction).”

While index will always be a whole number, leadPosition is a decimal number. Imagine running your finger down the strip. That’s leadPosition. So, if at some moment you were pointing at position 4.3, the pixels indexed 4 and 5 will be on.

The “-4” for green just shifts index back by 4 pixels, so green will follow red.

Does that help?


This helps. Let see if I can say what I see happening in the code and please correct any inaccuracies:

  1. red = green = blue = 0
    // each color set to 0 (off)

2). leadPosition = time(0.8) * pixelCount
// you are using time() which progresses from 0 - 1 then wraps (e.g. sawtooth wave)
// to do the following:
1: Progress through each index on the strip by * pixelCount
2: Set the speed of the progression through each index

3). red = abs(leadPosition - index - 0) < 1
//. Here you take the value of the difference between lead position
//. and the index (actual pixel being evaluated)
//. You a take the abs and use this value in a Boolean statement

Index red = abs(leadPosition - index - 0) < 1
0 red = abs (0 - 0 - 0) < 1 // true so red = 1 – turned on pixel at index 0

                 red = green = blue = 0 // resets all pixels to 0 or turns them off
                 Note: as long as the Boolean statement is true - the red pixel at index 0 is turned
                          back on

  1             red = abs (1 - 1 - 0) < 1 // true so red = 1 or turned on
                 red = green = blue = 0 // resets all pixels to 0 or turns them off

                Note: as long as the Boolean statement is true - the red pixel at index 1 is turned
                          back on

Each time the code evaluates for the next index, it resets the arguments in the rgb () to 0
Yet, I see two red LEDs that are turned on and progressing around the strip, and not one red LED as I would expect. How is this possible?

                                                            // as a mechanism to

You got it. Great read through.

Two pixels are within 1 pixel of a position most of the time. If leadPosition happens to be 4.3 when render is called for indices 3, 4, 5, & 6, those LEDs will be off, on, on, off. That’s because 4 and 5 are both within 1 of 4.3.

1 Like

Wow! Now I understand. Thank you Jeff! Again, much appreciated.

1 Like