Clearing LEDs on strip before running a program

&& is “and”
|| is “or”

That’s your missing piece.

Yes, you got it. I describe the Pixelblaze “engine” as this:

Stroke 1: before_render()
Optional, as you don’t need it, but it runs prior to the render, so good for things to do once per “frame”

Stroke 2: render() (or render2D(), or render3D() )
This runs many times per frame, starting at pixel zero, and runs each time until the last one is pixelCount -1
(So with 100 pixels, the last would be 99)

One thing to be clear: changing the “index” doesn’t change the actual pixel being focused on. So changing index from 50 to 99 doesn’t make it change pixel 99, we’re just saying "hey, yes you are working on pixel 50… But look, pretend it’s actually pixel 99, so you “do the right thing” when you figure out what to do.