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

◆ nscale8x3_video()

LIB8STATIC void nscale8x3_video ( 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), ensuring that non-zero values passed in remain non-zero, no matter how low the scale argument.

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 401 of file scale8.h.

402 {
403#if SCALE8_C == 1
404 uint8_t nonzeroscale = (scale != 0) ? 1 : 0;
405 r = (r == 0) ? 0 : (((int)r * (int)(scale)) >> 8) + nonzeroscale;
406 g = (g == 0) ? 0 : (((int)g * (int)(scale)) >> 8) + nonzeroscale;
407 b = (b == 0) ? 0 : (((int)b * (int)(scale)) >> 8) + nonzeroscale;
408#elif SCALE8_AVRASM == 1
412 cleanup_R1();
413#else
414#error "No implementation for nscale8x3 available."
415#endif
416}
uint16_t scale
Definition Noise.ino:74
LIB8STATIC_ALWAYS_INLINE void cleanup_R1()
Clean up the r1 register after a series of *LEAVING_R1_DIRTY calls.
Definition scale8.h:343
LIB8STATIC_ALWAYS_INLINE void nscale8_video_LEAVING_R1_DIRTY(uint8_t &i, fract8 scale)
In place modifying version of scale8_video() that does not clean up the R1 register on AVR.
Definition scale8.h:321

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

Referenced by fl::ColorFromPaletteExtended().

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