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

◆ map_data_into_colors_through_palette()

template<typename PALETTE>
void map_data_into_colors_through_palette ( uint8_t * dataArray,
uint16_t dataCount,
CRGB * targetColorArray,
const PALETTE & pal,
uint8_t brightness = 255,
uint8_t opacity = 255,
TBlendType blendType = LINEARBLEND )

Maps an array of palette color indexes into an array of LED colors.

This function provides an easy way to create lightweight color patterns that can be deployed using any palette.

Parameters
dataArraythe source array, containing color indexes for the palette
dataCountthe number of data elements in the array
targetColorArraythe LED array to store the resulting colors into. Must be at least as long as dataCount.
palthe color palette to pull colors from
brightnessoptional brightness value used to scale the resulting color
opacityoptional opacity value for the new color. If this is 255 (default), the new colors will be written to the array directly. Otherwise the existing LED data will be scaled down using CRGB::nscale8_video() and then new colors will be added on top. A higher value means that the new colors will be more visible.
blendTypewhether to take the palette entries directly (NOBLEND) or blend linearly between palette entries (LINEARBLEND)

Definition at line 2152 of file colorutils.h.

2159{
2160 for( uint16_t i = 0; i < dataCount; ++i) {
2161 uint8_t d = dataArray[i];
2162 CRGB rgb = ColorFromPalette( pal, d, brightness, blendType);
2163 if( opacity == 255 ) {
2164 targetColorArray[i] = rgb;
2165 } else {
2166 targetColorArray[i].nscale8( 256 - opacity);
2167 rgb.nscale8_video( opacity);
2168 targetColorArray[i] += rgb;
2169 }
2170 }
2171}
UISlider brightness("Brightness", 255, 0, 255, 1)
CRGB ColorFromPalette(const CRGBPalette16 &pal, uint8_t index, uint8_t brightness=255, TBlendType blendType=LINEARBLEND)
Get a color from a palette.
FASTLED_FORCE_INLINE CRGB & nscale8_video(uint8_t scaledown)
Scale down a RGB to N/256ths of it's current brightness using "video" dimming rules.
Definition crgb.hpp:78
CRGB & nscale8(uint8_t scaledown)
Scale down a RGB to N/256ths of its current brightness, using "plain math" dimming rules.
Definition crgb.cpp:72
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:54

References brightness, ColorFromPalette(), LINEARBLEND, CRGB::nscale8(), and CRGB::nscale8_video().

+ Here is the call graph for this function: