FastLED 3.10.6
Loading...
Searching...
No Matches

◆ nblendPaletteTowardPalette()

void fl::nblendPaletteTowardPalette ( CRGBPalette16 & current,
CRGBPalette16 & target,
fl::u8 maxChanges )
Examples
TwinkleFox.ino.

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

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

Referenced by loop().

+ Here is the caller graph for this function: