FastLED 3.9.15
|
void nblendPaletteTowardPalette | ( | CRGBPalette16 & | currentPalette, |
CRGBPalette16 & | targetPalette, | ||
uint8_t | maxChanges = 24 ) |
Alter one palette by making it slightly more like a "target palette".
Used for palette cross-fades.
It does this by comparing each of the R, G, and B channels of each entry in the current palette to the corresponding entry in the target palette and making small adjustments:
...and so on and so forth for the CRGB::green and CRGB::blue channels.
Additionally, there are two significant visual improvements to this algorithm implemented here. First is this:
Due to the way the eye perceives light, and the way colors are represented in RGB, this produces a more uniform apparent brightness when cross-fading between most palette colors.
The second visual tweak is limiting the number of changes that will be made to the palette at once. If all the palette entries are changed at once, it can give a muddled appearance. However, if only a few palette entries are changed at once, you get a visually smoother transition: in the middle of the cross-fade your current palette will actually contain some colors from the old palette, a few blended colors, and some colors from the new palette.
currentPalette | the palette to modify |
targetPalette | the palette to move towards |
maxChanges | the maximum number of possible palette changes to make to the color channels per call. The limit is 48 (16 color entries times 3 channels each). The default is 24, meaning that only half of the palette entries can be changed per call. |
currentPalette
will be modified! Be sure to make a copy beforehand if needed. targetPalette
be const
? Definition at line 1365 of file colorutils.cpp.
References CRGBPalette16::entries.
Referenced by fl::TwinkleFox::draw(), and loop().