FastLED 3.9.15
Loading...
Searching...
No Matches

◆ nblendPaletteTowardPalette()

void fl::nblendPaletteTowardPalette ( CRGBPalette16 & current,
CRGBPalette16 & target,
uint8_t maxChanges )

Definition at line 1017 of file colorutils.cpp.

1018 {
1019 uint8_t *p1;
1020 uint8_t *p2;
1021 uint8_t changes = 0;
1022
1023 p1 = (uint8_t *)current.entries;
1024 p2 = (uint8_t *)target.entries;
1025
1026 const uint8_t totalChannels = sizeof(CRGBPalette16);
1027 for (uint8_t i = 0; i < totalChannels; ++i) {
1028 // if the values are equal, no changes are needed
1029 if (p1[i] == p2[i]) {
1030 continue;
1031 }
1032
1033 // if the current value is less than the target, increase it by one
1034 if (p1[i] < p2[i]) {
1035 ++p1[i];
1036 ++changes;
1037 }
1038
1039 // if the current value is greater than the target,
1040 // increase it by one (or two if it's still greater).
1041 if (p1[i] > p2[i]) {
1042 --p1[i];
1043 ++changes;
1044 if (p1[i] > p2[i]) {
1045 --p1[i];
1046 }
1047 }
1048
1049 // if we've hit the maximum number of changes, exit
1050 if (changes >= maxChanges) {
1051 break;
1052 }
1053 }
1054}

Referenced by fl::TwinkleFox::draw().

+ Here is the caller graph for this function: