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
-
r | first value to scale |
g | second value to scale |
b | third value to scale |
scale | scale factor, in n/256 units |
Definition at line 357 of file scale8.h.
357 {
358#if SCALE8_C == 1
359#if (FASTLED_SCALE8_FIXED == 1)
360 uint16_t scale_fixed =
scale + 1;
361 r = (((uint16_t)r) * scale_fixed) >> 8;
362 g = (((uint16_t)g) * scale_fixed) >> 8;
363 b = (((uint16_t)b) * scale_fixed) >> 8;
364#else
365 r = ((int)r * (int)(
scale)) >> 8;
366 g = ((int)g * (int)(
scale)) >> 8;
367 b = ((int)b * (int)(
scale)) >> 8;
368#endif
369#elif SCALE8_AVRASM == 1
374#else
375#error "No implementation for nscale8x3 available."
376#endif
377}
UISlider scale("Scale", 4,.1, 4,.1)
LIB8STATIC_ALWAYS_INLINE void cleanup_R1()
Clean up the r1 register after a series of *LEAVING_R1_DIRTY calls.
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.
References cleanup_R1(), LIB8STATIC, scale, and scale8_LEAVING_R1_DIRTY().
Referenced by ColorFromPaletteExtended(), ColorFromPaletteExtended(), CRGB::fadeToBlackBy(), MyColorFromPaletteExtended(), CRGB::nscale8(), and CRGB::scale8().