What would be the fastest way to map (and filter) one CRGB to another one? Create a weighted averaging of the involved pixels based on leds[i].nscale8 and then add the results?
Check out the “blend” (and “nblend”) functions in colorutils.h:
// blend - computes a new color
// blended some fraction of the way
// between two other colors.
CRGB blend(
const CRGB& p1,
const CRGB& p2,
fract8 amountOfP2 );
Is this the sort of thing you were thinking?
CRGB also provides getAverageLight and getLuma if those are relevant.
Maybe I’m confused about what you would ideally like to use. What hypothetical API would you want to have?
Thanks Mark! If I understand it right, the functions are meant to blend between 2 pixels. Is that performant for a bilinear filtering or for methods which involve even more than the 4 surrounding pixels?
Right now I love the idea to render into a matrix with a higher resolution than the actual output device has and then not just scale the result down, but interpolate between relevant pixels for a smooth high quality animation (while loosing a bit of contrast).
P.S. getAverageLight is relevant for an other side project - a ambilight that softens every frame except when it’s about fading to (nearly) black which has to happen instantly. Thanks for reminding the name of the function!
So you’re thinking something like: generate your animation data into a 50 x 50 data matrix, but then render it visually on a 16 x 16 LED matrix?
Yes, that is the idea.
Or to render a 16x16 while knowing that I need at the end just data for 32 leds arranged in a circle.