MCPcopy Create free account
hub / github.com/FastLED/FastLED / fill_gradient_RGB

Function fill_gradient_RGB

src/fl/gfx/fill.cpp.hpp:107–147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105}
106
107void fill_gradient_RGB(CRGB *leds, u16 startpos, CRGB startcolor,
108 u16 endpos, CRGB endcolor) {
109 // if the points are in the wrong order, straighten them
110 if (endpos < startpos) {
111 u16 t = endpos;
112 CRGB tc = endcolor;
113 endcolor = startcolor;
114 endpos = startpos;
115 startpos = t;
116 startcolor = tc;
117 }
118
119 saccum87 rdistance87;
120 saccum87 gdistance87;
121 saccum87 bdistance87;
122
123 rdistance87 = (endcolor.r - startcolor.r) << 7;
124 gdistance87 = (endcolor.g - startcolor.g) << 7;
125 bdistance87 = (endcolor.b - startcolor.b) << 7;
126
127 u16 pixeldistance = endpos - startpos;
128 i16 divisor = pixeldistance ? pixeldistance : 1;
129
130 saccum87 rdelta87 = rdistance87 / divisor;
131 saccum87 gdelta87 = gdistance87 / divisor;
132 saccum87 bdelta87 = bdistance87 / divisor;
133
134 rdelta87 *= 2;
135 gdelta87 *= 2;
136 bdelta87 *= 2;
137
138 accum88 r88 = startcolor.r << 8;
139 accum88 g88 = startcolor.g << 8;
140 accum88 b88 = startcolor.b << 8;
141 for (u16 i = startpos; i <= endpos; ++i) {
142 leds[i] = CRGB(r88 >> 8, g88 >> 8, b88 >> 8);
143 r88 += rdelta87;
144 g88 += gdelta87;
145 b88 += bdelta87;
146 }
147}
148
149void fill_gradient_RGB(CRGB *leds, u16 numLeds, const CRGB &c1,
150 const CRGB &c2) {

Callers

nothing calls this directly

Calls 1

CRGBClass · 0.70

Tested by

no test coverage detected