FastLED 3.10.8
Loading...
Searching...
No Matches

◆ nblendPaletteTowardPalette()

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

Definition at line 1333 of file colorutils.cpp.hpp.

1334 {
1335 if (maxChanges == 0) {
1336 return;
1337 }
1338
1339 fl::u8 *p1;
1340 fl::u8 *p2;
1341 fl::u8 changes = 0;
1342
1343 p1 = (fl::u8 *)current.entries;
1344 p2 = (fl::u8 *)target.entries;
1345
1346 const fl::u8 totalChannels = sizeof(CRGBPalette16);
1347 for (fl::u8 i = 0; i < totalChannels; ++i) {
1348 // if the values are equal, no changes are needed
1349 if (p1[i] == p2[i]) {
1350 continue;
1351 }
1352
1353 // if the current value is less than the target, increase it by one
1354 if (p1[i] < p2[i]) {
1355 ++p1[i];
1356 ++changes;
1357 }
1358
1359 // if the current value is greater than the target,
1360 // increase it by one (or two if it's still greater).
1361 if (p1[i] > p2[i]) {
1362 --p1[i];
1363 ++changes;
1364 if (p1[i] > p2[i]) {
1365 --p1[i];
1366 }
1367 }
1368
1369 // if we've hit the maximum number of changes, exit
1370 if (changes >= maxChanges) {
1371 break;
1372 }
1373 }
1374}
unsigned char u8
Definition stdint.h:131

References FL_NO_EXCEPT.

Referenced by fl::TwinkleFox::draw(), and FL_DISABLE_WARNING().

+ Here is the caller graph for this function: