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

◆ fadeUsingColor()

void fadeUsingColor ( CRGB * leds,
uint16_t numLeds,
const CRGB & colormask )

Reduce the brightness of an array of pixels as thought it were seen through a transparent filter with the specified color.

For example, if the colormask if CRGB(200, 100, 50), then the pixels' red will be faded to 200/256ths, their green to 100/256ths, and their blue to 50/256ths. This particular example will give a "hot fade" look, with white fading to yellow, then red, then black. You can also use colormasks like CRGB::Blue to zero out the red and green elements, leaving blue (largely) the same.

Parameters
ledsa pointer to the LED array to fade
numLedsthe number of LEDs to fade
colormaskthe color mask to fade with

Definition at line 288 of file colorutils.cpp.

289{
290 uint8_t fr, fg, fb;
291 fr = colormask.r;
292 fg = colormask.g;
293 fb = colormask.b;
294
295 for( uint16_t i = 0; i < numLeds; ++i) {
296 leds[i].r = scale8_LEAVING_R1_DIRTY( leds[i].r, fr);
297 leds[i].g = scale8_LEAVING_R1_DIRTY( leds[i].g, fg);
298 leds[i].b = scale8 ( leds[i].b, fb);
299 }
300}
CRGB leds[NUM_LEDS]
Definition Apa102.ino:11
LIB8STATIC_ALWAYS_INLINE uint8_t scale8_LEAVING_R1_DIRTY(uint8_t i, fract8 scale)
This version of scale8() does not clean up the R1 register on AVR.
Definition scale8.h:170
LIB8STATIC_ALWAYS_INLINE uint8_t scale8(uint8_t i, fract8 scale)
Scale one byte by a second one, which is treated as the numerator of a fraction whose denominator is ...
Definition scale8.h:34

References leds, scale8(), and scale8_LEAVING_R1_DIRTY().

+ Here is the call graph for this function: