FastLED 3.9.15
Loading...
Searching...
No Matches

◆ blur1d() [2/2]

void fl::gfx::blur1d ( fl::span< CRGB > leds,
fract8 blur_amount )

One-dimensional blur filter (span version).

Spreads light to 2 line 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 all the way to black; this is by design so that it can be used to (slowly) clear the LEDs to black.

Parameters
ledsspan of LEDs to blur
blur_amountthe amount of blur to apply

Definition at line 69 of file blur.cpp.hpp.

69 {
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}
fl::CRGB leds[NUM_LEDS]
unsigned char u8
Definition s16x16x4.h:132
u8 u8 fract8 blur_amount
Definition blur.h:186
CRGB & nscale8(u8 scaledown) FL_NOEXCEPT
Scale down a RGB to N/256ths of its current brightness, using "plain math" dimming rules.
Definition crgb.cpp.hpp:88
@ Black
<div style='background:#000000;width:4em;height:4em;'></div>
Definition crgb.h:510
Representation of an 8-bit RGB pixel (Red, Green, Blue)
Definition crgb.h:38

References fl::CRGB::Black, fl::blur_amount, fl::cur, leds, and fl::CRGB::nscale8().

Referenced by fl::blur1d(), fl::blur1d(), and blur1d().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: