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

◆ nblend() [3/4]

CRGB & nblend ( CRGB & existing,
const CRGB & overlay,
fract8 amountOfOverlay )

Destructively modifies one color, blending in a given fraction of an overlay color.

Parameters
existingthe color to modify
overlaythe color to blend into existing
amountOfOverlaythe fraction of overlay to blend into existing

Definition at line 303 of file colorutils.cpp.

304{
305 if( amountOfOverlay == 0) {
306 return existing;
307 }
308
309 if( amountOfOverlay == 255) {
310 existing = overlay;
311 return existing;
312 }
313
314#if 0
315 // Old blend method which unfortunately had some rounding errors
316 fract8 amountOfKeep = 255 - amountOfOverlay;
317
318 existing.red = scale8_LEAVING_R1_DIRTY( existing.red, amountOfKeep)
319 + scale8_LEAVING_R1_DIRTY( overlay.red, amountOfOverlay);
320 existing.green = scale8_LEAVING_R1_DIRTY( existing.green, amountOfKeep)
321 + scale8_LEAVING_R1_DIRTY( overlay.green, amountOfOverlay);
322 existing.blue = scale8_LEAVING_R1_DIRTY( existing.blue, amountOfKeep)
323 + scale8_LEAVING_R1_DIRTY( overlay.blue, amountOfOverlay);
324
325 cleanup_R1();
326#else
327 // Corrected blend method, with no loss-of-precision rounding errors
328 existing.red = blend8( existing.red, overlay.red, amountOfOverlay);
329 existing.green = blend8( existing.green, overlay.green, amountOfOverlay);
330 existing.blue = blend8( existing.blue, overlay.blue, amountOfOverlay);
331#endif
332
333 return existing;
334}
uint8_t fract8
ANSI: unsigned short _Fract.
Definition types.h:36
LIB8STATIC uint8_t blend8(uint8_t a, uint8_t b, uint8_t amountOfB)
Blend a variable proportion (0-255) of one byte to another.
Definition math8.h:667
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 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

References blend8(), cleanup_R1(), and scale8_LEAVING_R1_DIRTY().

Referenced by blend(), blend(), fl::Pride2015::draw(), nblend(), nblend(), and pride().

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