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.
- Parameters
-
| leds | a pointer to the LED array to fill |
| startpos | the starting position in the array |
| startcolor | the starting color for the gradient |
| endpos | the ending position in the array |
| endcolor | the end color for the gradient |
Definition at line 108 of file fill.cpp.hpp.
109 {
110
111 if (endpos < startpos) {
114 endcolor = startcolor;
115 endpos = startpos;
117 startcolor = tc;
118 }
119
123
124
125 rdistance87 = (endcolor.r - startcolor.r) * 128;
126 gdistance87 = (endcolor.g - startcolor.g) * 128;
127 bdistance87 = (endcolor.b - startcolor.b) * 128;
128
129 u16 pixeldistance = endpos - startpos;
130 i16 divisor = pixeldistance ? pixeldistance : 1;
131
132 saccum87 rdelta87 = rdistance87 / divisor;
133 saccum87 gdelta87 = gdistance87 / divisor;
134 saccum87 bdelta87 = bdistance87 / divisor;
135
136 rdelta87 *= 2;
137 gdelta87 *= 2;
138 bdelta87 *= 2;
139
140 accum88 r88 = startcolor.r << 8;
141 accum88 g88 = startcolor.g << 8;
142 accum88 b88 = startcolor.b << 8;
143 for (u16 i = startpos; i <= endpos; ++i) {
144 leds[i] =
CRGB(r88 >> 8, g88 >> 8, b88 >> 8);
145 r88 += rdelta87;
146 g88 += gdelta87;
147 b88 += bdelta87;
148 }
149}
#define saccum87
ANSI: signed short _Accum.
u16 accum88
ANSI: unsigned short _Accum. 8 bits int, 8 bits fraction.
Representation of an 8-bit RGB pixel (Red, Green, Blue)
References FL_NO_EXCEPT, leds, saccum87, and t.
Referenced by fill_gradient_RGB(), fill_gradient_RGB(), fill_gradient_RGB(), fill_gradient_RGB(), fill_gradient_RGB(), and fill_gradient_RGB().