Fill a range of LEDs with a smooth RGB gradient between two RGB colors.
Unlike HSV, there is no "color wheel" in RGB space, and therefore there's only one "direction" for the gradient to go. This means there's no TGradientDirectionCode parameter for direction.
108 {
109
110 if (endpos < startpos) {
113 endcolor = startcolor;
114 endpos = startpos;
116 startcolor = tc;
117 }
118
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}
#define saccum87
ANSI: signed short _Accum.
u16 accum88
ANSI: unsigned short _Accum. 8 bits int, 8 bits fraction.
Representation of an RGB pixel (Red, Green, Blue)