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

◆ ColorFromPalette() [5/8]

CRGB ColorFromPalette ( const CRGBPalette256 & pal,
uint8_t index,
uint8_t brightness = 255,
TBlendType blendType = NOBLEND )

Get a color from a palette.

These are the main functions for getting and using palette colors. Regardless of the number of entries in the base palette, this function will interpolate between entries to turn the discrete colors into a smooth gradient.

Parameters
palthe palette to retrieve the color from
indexthe position in the palette to retrieve the color for (0-255)
brightnessoptional brightness value to scale the resulting color
blendTypewhether to take the palette entries directly (NOBLEND) or blend linearly between palette entries (LINEARBLEND)

Definition at line 1046 of file colorutils.cpp.

1047{
1048 const CRGB* entry = &(pal[0]) + index;
1049
1050 uint8_t red = entry->red;
1051 uint8_t green = entry->green;
1052 uint8_t blue = entry->blue;
1053
1054 if( brightness != 255) {
1055 ++brightness; // adjust for rounding
1059 cleanup_R1();
1060 }
1061
1062 return CRGB( red, green, blue);
1063}
UISlider brightness("Brightness", 255, 0, 255, 1)
LIB8STATIC_ALWAYS_INLINE void cleanup_R1()
Clean up the r1 register after a series of *LEAVING_R1_DIRTY calls.
Definition scale8.h:333
LIB8STATIC_ALWAYS_INLINE uint8_t scale8_video_LEAVING_R1_DIRTY(uint8_t i, fract8 scale)
This version of scale8_video() does not clean up the R1 register on AVR.
Definition scale8.h:262
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:54

References brightness, cleanup_R1(), and scale8_video_LEAVING_R1_DIRTY().

+ Here is the call graph for this function: