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

◆ nblendPaletteTowardPalette()

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

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

1252 {
1253 fl::u8 *p1;
1254 fl::u8 *p2;
1255 fl::u8 changes = 0;
1256
1257 p1 = (fl::u8 *)current.entries;
1258 p2 = (fl::u8 *)target.entries;
1259
1260 const fl::u8 totalChannels = sizeof(CRGBPalette16);
1261 for (fl::u8 i = 0; i < totalChannels; ++i) {
1262 // if the values are equal, no changes are needed
1263 if (p1[i] == p2[i]) {
1264 continue;
1265 }
1266
1267 // if the current value is less than the target, increase it by one
1268 if (p1[i] < p2[i]) {
1269 ++p1[i];
1270 ++changes;
1271 }
1272
1273 // if the current value is greater than the target,
1274 // increase it by one (or two if it's still greater).
1275 if (p1[i] > p2[i]) {
1276 --p1[i];
1277 ++changes;
1278 if (p1[i] > p2[i]) {
1279 --p1[i];
1280 }
1281 }
1282
1283 // if we've hit the maximum number of changes, exit
1284 if (changes >= maxChanges) {
1285 break;
1286 }
1287 }
1288}
unsigned char u8
Definition s16x16x4.h:132

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

+ Here is the caller graph for this function: