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

392 {
393#if SCALE8_C == 1
394 uint8_t nonzeroscale = (scale != 0) ? 1 : 0;
395 r = (r == 0) ? 0 : (((int)r * (int)(scale)) >> 8) + nonzeroscale;
396 g = (g == 0) ? 0 : (((int)g * (int)(scale)) >> 8) + nonzeroscale;
397 b = (b == 0) ? 0 : (((int)b * (int)(scale)) >> 8) + nonzeroscale;
398#elif SCALE8_AVRASM == 1
402 cleanup_R1();
403#else
404#error "No implementation for nscale8x3 available."
405#endif
406}
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.
Definition scale8.h:333
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:311

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

Referenced by ColorFromPaletteExtended(), CRGB::fadeLightBy(), CRGB::nscale8_video(), and CRGB::operator%=().

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