You can return an array, see my Complex Number code for an example.
I’m going to say it depends on if you need access to the index… if this is a fixed layout, where you know specific index values should be left alone (or whatever), then you might be better off… but really if you can calculate it all that way, what’s the advantage to using before_render
? Might as well make the code simpler. Sometimes pixel buffers make sense, but usually you need to have a need for data (what pixels are lit, for example) for them to do so.
In this case, with a set of pixels that you’ve mapped (like fender post verticals), I think you’re doing it right: the mask lets you override pixels by location. You need render’s awareness of index, though, to decide on the location, and compare to your mask
Doing the opposite in the name of a smaller array, (so a list of just what pixels to mask), would be a smaller array, but you’d have to do more work to pull out the data. Is this pixel one of the masked ones, you’d have to look thru the entire array, because there is no easy ‘array contains’ type function. Might as well make the lookup trivial, faster at the expense of size. The ‘noneasy’ version uses arrayReduce.
- Count instances of value:
key = valueyouseek; arrayReduce(a, (acc, v) => acc + (v == valueyouseek), 0)