FastLED 3.10.8
Loading...
Searching...
No Matches

◆ nblend()

CRGB & fl::nblend ( CRGB & existing,
const CRGB & overlay,
fract8 amountOfOverlay )
Examples
Pride2015.ino.

Definition at line 88 of file colorutils.cpp.hpp.

88 {
89 if (amountOfOverlay == 0) {
90 return existing;
91 }
92
93 if (amountOfOverlay == 255) {
94 existing = overlay;
95 return existing;
96 }
97
98#if 0
99 // Old blend method which unfortunately had some rounding errors
100 fract8 amountOfKeep = 255 - amountOfOverlay;
101
102 existing.red = scale8_LEAVING_R1_DIRTY( existing.red, amountOfKeep)
103 + scale8_LEAVING_R1_DIRTY( overlay.red, amountOfOverlay);
104 existing.green = scale8_LEAVING_R1_DIRTY( existing.green, amountOfKeep)
105 + scale8_LEAVING_R1_DIRTY( overlay.green, amountOfOverlay);
106 existing.blue = scale8_LEAVING_R1_DIRTY( existing.blue, amountOfKeep)
107 + scale8_LEAVING_R1_DIRTY( overlay.blue, amountOfOverlay);
108
109 cleanup_R1();
110#else
111 // Corrected blend method, with no loss-of-precision rounding errors
112 existing.red = blend8(existing.red, overlay.red, amountOfOverlay);
113 existing.green = blend8(existing.green, overlay.green, amountOfOverlay);
114 existing.blue = blend8(existing.blue, overlay.blue, amountOfOverlay);
115#endif
116
117 return existing;
118}
u8 fract8
Fixed-Point Fractional Types.
Definition stdint.h:160