Specific pixels in a specific node

Hi folks! I’m wondering if it’s possible to isolate a specific range of pixels within a specific node without having to specify the overall range of pixels using “index”. For example, let’s say I have five nodes at 1000 pixels each, and I would like to write a condition that would be true if the pixel is in the last 500 of node 2 or all of node 3 or the first 500 of node 4. I know I could say:

if ((index => 2500 && index <=2999) II nodeId() == 3 || (index => 4000 && index <= 4499)) {}

Is there any way to instead code it as "the 501st through 1000th pixel of node 2?" I think this would be necessary in case node 0 were to get disconnected, which I believe would cause index = 0 to move from the first pixel of node 0 to the first pixel of node 1, at least temporarily. Thank you in advance!
Best,
Marty

If you’re using 1D or 2D mapping, an easy way to handle this is by using 3D mapping.
You put a specific value for led in Z for each segment (so technically you can have as many “segments” as you want.

Then in your code you just execute as “if z= then execute the specific code for this segment”

I use it to “ignore” some of my pixels and make sure they will never light up.

2 Likes

(sorry about my code formatting above)
OK that’s an elegant solution, thank you. Reminds me of the old school animation cels - layer 1 on top of layer 2 on top of layer 3. Will try that. Only slight downside is if I need to move a group to another layer I will need to find and replace with the Z coordinates rather than change the code but that’s manageable. Thanks!

Hi again - I think there may be some syntax I’m missing. I’m trying to isolate the pixels in which z=1 in this function in @zranger1 's multimap program, but the condition is not being met:

function inmap1 (index, x, y, z) {
  if (z = 1) {    
    isInMap = true;
    }
}

I also tried “z == 1” but that doesn’t seem to work either. I seem to recall in the multimap examples that the actual range of x and y is 0 to 1, which might explain my issue. If that’s also the case for z then is there a good strategy for isolating one layer? Perhaps if one has 6 layers and to get the 2nd layer z would be between 1/12 and 3/12? Thanks.

Maybe the mapper tool has normalized your X and Y and made Z a bit small.

Try pasting your mapper function into your browser’s JS console. It will dump out the actual values. (Uh, that’s the values before the PB does whatever normalization you have selected!)

You could also try if (z > 0) { but if that works you didn’t learn very much!