| 170 | } |
| 171 | |
| 172 | void blurColumns(fl::span<CRGB> leds, fl::u8 width, fl::u8 height, |
| 173 | fract8 blur_amount, const XYMap &xyMap) { |
| 174 | CRGB *pixels = leds.data(); |
| 175 | fl::u8 keep = 255 - blur_amount; |
| 176 | fl::u8 seep = blur_amount >> 1; |
| 177 | if (xyMap.isRectangularGrid()) { |
| 178 | for (fl::u8 col = 0; col < width; ++col) { |
| 179 | CRGB carryover = CRGB::Black; |
| 180 | for (fl::u8 row = 0; row < height; ++row) { |
| 181 | CRGB cur = pixels[row * width + col]; |
| 182 | CRGB part = cur; |
| 183 | part.nscale8(seep); |
| 184 | cur.nscale8(keep); |
| 185 | cur += carryover; |
| 186 | if (row) |
| 187 | pixels[(row - 1) * width + col] += part; |
| 188 | pixels[row * width + col] = cur; |
| 189 | carryover = part; |
| 190 | } |
| 191 | } |
| 192 | return; |
| 193 | } |
| 194 | for (fl::u8 col = 0; col < width; ++col) { |
| 195 | CRGB carryover = CRGB::Black; |
| 196 | for (fl::u8 i = 0; i < height; ++i) { |
| 197 | CRGB cur = leds[xyMap.mapToIndex(col, i)]; |
| 198 | CRGB part = cur; |
| 199 | part.nscale8(seep); |
| 200 | cur.nscale8(keep); |
| 201 | cur += carryover; |
| 202 | if (i) |
| 203 | leds[xyMap.mapToIndex(col, i - 1)] += part; |
| 204 | leds[xyMap.mapToIndex(col, i)] = cur; |
| 205 | carryover = part; |
| 206 | } |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | void blurRows(Canvas<CRGB> &canvas, alpha8 blur_amount) { |
| 211 | const int w = canvas.width; |
no test coverage detected