| 103 | /// @param directionCode the direction to travel around the color wheel |
| 104 | template <typename T> |
| 105 | void fill_gradient(T *targetArray, u16 startpos, CHSV startcolor, |
| 106 | u16 endpos, CHSV endcolor, |
| 107 | TGradientDirectionCode directionCode = SHORTEST_HUES) FL_NOEXCEPT { |
| 108 | // if the points are in the wrong order, straighten them |
| 109 | if (endpos < startpos) { |
| 110 | u16 t = endpos; |
| 111 | CHSV tc = endcolor; |
| 112 | endcolor = startcolor; |
| 113 | endpos = startpos; |
| 114 | startpos = t; |
| 115 | startcolor = tc; |
| 116 | } |
| 117 | |
| 118 | // If we're fading toward black (val=0) or white (sat=0), |
| 119 | // then set the endhue to the starthue. |
| 120 | // This lets us ramp smoothly to black or white, regardless |
| 121 | // of what 'hue' was set in the endcolor (since it doesn't matter) |
| 122 | if (endcolor.value == 0 || endcolor.saturation == 0) { |
| 123 | endcolor.hue = startcolor.hue; |
| 124 | } |
| 125 | |
| 126 | // Similarly, if we're fading in from black (val=0) or white (sat=0) |
| 127 | // then set the starthue to the endhue. |
| 128 | // This lets us ramp smoothly up from black or white, regardless |
| 129 | // of what 'hue' was set in the startcolor (since it doesn't matter) |
| 130 | if (startcolor.value == 0 || startcolor.saturation == 0) { |
| 131 | startcolor.hue = endcolor.hue; |
| 132 | } |
| 133 | |
| 134 | saccum87 huedistance87; |
| 135 | saccum87 satdistance87; |
| 136 | saccum87 valdistance87; |
| 137 | |
| 138 | satdistance87 = (endcolor.sat - startcolor.sat) << 7; |
| 139 | valdistance87 = (endcolor.val - startcolor.val) << 7; |
| 140 | |
| 141 | fl::u8 huedelta8 = endcolor.hue - startcolor.hue; |
| 142 | |
| 143 | if (directionCode == SHORTEST_HUES) { |
| 144 | directionCode = FORWARD_HUES; |
| 145 | if (huedelta8 > 127) { |
| 146 | directionCode = BACKWARD_HUES; |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | if (directionCode == LONGEST_HUES) { |
| 151 | directionCode = FORWARD_HUES; |
| 152 | if (huedelta8 < 128) { |
| 153 | directionCode = BACKWARD_HUES; |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | if (directionCode == FORWARD_HUES) { |
| 158 | huedistance87 = huedelta8 << 7; |
| 159 | } else /* directionCode == BACKWARD_HUES */ |
| 160 | { |
| 161 | huedistance87 = (fl::u8)(256 - huedelta8) << 7; |
| 162 | huedistance87 = -huedistance87; |
no outgoing calls
no test coverage detected