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

◆ ColorFromPaletteExtended()

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

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

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

Referenced by fl::anonymous_namespace{gradient.cpp.hpp}::Visitor::accept(), and fl::anonymous_namespace{gradient.cpp.hpp}::VisitorFill::accept().

+ Here is the caller graph for this function: