blur1d: one-dimensional blur filter. Spreads light to 2 line neighbors. blur2d: two-dimensional blur filter. Spreads light to 8 XY neighbors. 0 = no spread at all 64 = moderate spreading 172 = maximum smooth, even spreading 173..255 = wider spreading, but increasing flicker Total light is NOT entirely conserved, so many repeated calls to 'blur' will also result in the light fading, eventually a
| 67 | // eventually all the way to black; this is by design so that |
| 68 | // it can be used to (slowly) clear the LEDs to black. |
| 69 | void blur1d(fl::span<CRGB> leds, fract8 blur_amount) { |
| 70 | const fl::u16 numLeds = static_cast<fl::u16>(leds.size()); |
| 71 | fl::u8 keep = 255 - blur_amount; |
| 72 | fl::u8 seep = blur_amount >> 1; |
| 73 | CRGB carryover = CRGB::Black; |
| 74 | for (fl::u16 i = 0; i < numLeds; ++i) { |
| 75 | CRGB cur = leds[i]; |
| 76 | CRGB part = cur; |
| 77 | part.nscale8(seep); |
| 78 | cur.nscale8(keep); |
| 79 | cur += carryover; |
| 80 | if (i) |
| 81 | leds[i - 1] += part; |
| 82 | leds[i] = cur; |
| 83 | carryover = part; |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | void blur2d(fl::span<CRGB> leds, fl::u8 width, fl::u8 height, |
| 88 | fract8 blur_amount, const XYMap &xymap) { |