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

◆ MyColorFromPaletteExtended()

fl::CRGB MyColorFromPaletteExtended ( const fl::CRGBPalette16 & pal,
uint16_t index,
uint8_t brightness,
TBlendType blendType )

Definition at line 39 of file FxWater.h.

39 {
40 // Extract the four most significant bits of the index as a palette index.
41 uint8_t index_4bit = (index >> 12);
42 // Calculate the 8-bit offset from the palette index.
43 uint8_t offset = (uint8_t)(index >> 4);
44 // Get the palette entry from the 4-bit index
45 const fl::CRGB* entry = &(pal[0]) + index_4bit;
46 uint8_t red1 = entry->red;
47 uint8_t green1 = entry->green;
48 uint8_t blue1 = entry->blue;
49
50 uint8_t blend = offset && (blendType != NOBLEND);
51 if (blend) {
52 if (index_4bit == 15) {
53 entry = &(pal[0]);
54 } else {
55 entry++;
56 }
57
58 // Calculate the scaling factor and scaled values for the lower palette value.
59 uint8_t f1 = 255 - offset;
60 red1 = scale8_LEAVING_R1_DIRTY(red1, f1);
61 green1 = scale8_LEAVING_R1_DIRTY(green1, f1);
62 blue1 = scale8_LEAVING_R1_DIRTY(blue1, f1);
63
64 // Calculate the scaled values for the neighbouring palette value.
65 uint8_t red2 = entry->red;
66 uint8_t green2 = entry->green;
67 uint8_t blue2 = entry->blue;
68 red2 = scale8_LEAVING_R1_DIRTY(red2, offset);
69 green2 = scale8_LEAVING_R1_DIRTY(green2, offset);
70 blue2 = scale8_LEAVING_R1_DIRTY(blue2, offset);
71 cleanup_R1();
72
73 // These sums can't overflow, so no qadd8 needed.
74 red1 += red2;
75 green1 += green2;
76 blue1 += blue2;
77 }
78 if (brightness != 255) {
79 // nscale8x3_video(red1, green1, blue1, brightness);
80 nscale8x3(red1, green1, blue1, brightness);
81 }
82 return fl::CRGB(red1, green1, blue1);
83}
fl::UISlider brightness("Brightness", BRIGHTNESS, 0, 255)
CRGB blend(const CRGB &p1, const CRGB &p2, fract8 amountOfP2)
fl::UISlider offset("Offset", 0.0f, 0.0f, 1.0f, 0.01f)
fl::CRGB CRGB
Definition video.h:15
unsigned char uint8_t
Definition s16x16x4.h:209
Representation of an 8-bit RGB pixel (Red, Green, Blue)
Definition crgb.h:38

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

Referenced by loop().

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