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

◆ nscale8x3()

LIB8STATIC void nscale8x3 ( uint8_t & r,
uint8_t & g,
uint8_t & b,
fract8 scale )

Scale three one-byte values by a fourth one, which is treated as the numerator of a fraction whose demominator is 256.

In other words, it computes r,g,b * (scale / 256)

Warning
This function always modifies its arguments in place!
Parameters
rfirst value to scale
gsecond value to scale
bthird value to scale
scalescale factor, in n/256 units

Definition at line 363 of file scale8.h.

363 {
364#if SCALE8_C == 1
365#if (FASTLED_SCALE8_FIXED == 1)
366 uint16_t scale_fixed = scale + 1;
367 r = (((uint16_t)r) * scale_fixed) >> 8;
368 g = (((uint16_t)g) * scale_fixed) >> 8;
369 b = (((uint16_t)b) * scale_fixed) >> 8;
370#else
371 r = ((int)r * (int)(scale)) >> 8;
372 g = ((int)g * (int)(scale)) >> 8;
373 b = ((int)b * (int)(scale)) >> 8;
374#endif
375#elif SCALE8_AVRASM == 1
379 cleanup_R1();
380#else
381#error "No implementation for nscale8x3 available."
382#endif
383}
UISlider scale("Scale", 1.0f, 0.0f, 1.0f, 0.01f)
LIB8STATIC_ALWAYS_INLINE void cleanup_R1()
Clean up the r1 register after a series of *LEAVING_R1_DIRTY calls.
Definition scale8.h:339
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:176

References cleanup_R1(), LIB8STATIC, scale, and scale8_LEAVING_R1_DIRTY().

Referenced by fl::ColorFromPaletteExtended(), fl::ColorFromPaletteExtended(), CRGB::fadeToBlackBy(), MyColorFromPaletteExtended(), CRGB::nscale8(), and CRGB::scale8().

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