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

◆ ColorFromPaletteExtended() [3/5]

CRGB fl::ColorFromPaletteExtended ( const CRGBPalette32 & pal,
fl::u16 index,
fl::u8 brightness,
TBlendType blendType )

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

422 {
423 // Extract the five most significant bits of the index as a palette index.
424 fl::u8 index_5bit = (index >> 11);
425 // Calculate the 8-bit offset from the palette index.
426 fl::u8 offset = (fl::u8)(index >> 3);
427 // Get the palette entry from the 5-bit index
428 const CRGB *entry = &(pal[0]) + index_5bit;
429 fl::u8 red1 = entry->red;
430 fl::u8 green1 = entry->green;
431 fl::u8 blue1 = entry->blue;
432
433 fl::u8 blend = offset && (blendType != NOBLEND);
434 if (blend) {
435 if (index_5bit == 31) {
436 entry = &(pal[0]);
437 } else {
438 entry++;
439 }
440
441 // Calculate the scaling factor and scaled values for the lower palette
442 // value.
443 fl::u8 f1 = 255 - offset;
444 red1 = scale8_LEAVING_R1_DIRTY(red1, f1);
445 green1 = scale8_LEAVING_R1_DIRTY(green1, f1);
446 blue1 = scale8_LEAVING_R1_DIRTY(blue1, f1);
447
448 // Calculate the scaled values for the neighbouring palette value.
449 fl::u8 red2 = entry->red;
450 fl::u8 green2 = entry->green;
451 fl::u8 blue2 = entry->blue;
452 red2 = scale8_LEAVING_R1_DIRTY(red2, offset);
453 green2 = scale8_LEAVING_R1_DIRTY(green2, offset);
454 blue2 = scale8_LEAVING_R1_DIRTY(blue2, offset);
455 cleanup_R1();
456
457 // These sums can't overflow, so no qadd8 needed.
458 red1 += red2;
459 green1 += green2;
460 blue1 += blue2;
461 }
462 if (brightness != 255) {
463 // nscale8x3_video(red1, green1, blue1, brightness);
464 nscale8x3(red1, green1, blue1, brightness);
465 }
466 return CRGB(red1, green1, blue1);
467}
fl::UISlider brightness("Brightness", BRIGHTNESS, 0, 255)
fl::UISlider offset("Offset", 0.0f, 0.0f, 1.0f, 0.01f)
unsigned char u8
Definition stdint.h:131
fl::CRGB CRGB
Definition video.h:18
CRGB blend(const CRGB &p1, const CRGB &p2, fract8 amountOfP2)
Representation of an 8-bit RGB pixel (Red, Green, Blue)
Definition crgb.h:38

References blend(), brightness, and offset().

Referenced by FL_DISABLE_WARNING().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: