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

◆ blur2d() [2/4]

void fl::gfx::blur2d ( CRGB * leds,
u8 width,
u8 height,
fract8 blur_amount )

Legacy version of blur2d, which does not require an XYMap but instead implicitly binds to XY() function.

If you are hitting a linker error here, then use blur2d(..., const fl::XYMap& xymap) instead.

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

93 {
94 // Legacy path: uses global XY() via XYMap for user-defined layouts.
95 // Keeps its own blur algorithm copy because XYMap indexing differs from
96 // the cache-coherent rectangular layout used by Canvas.
97 XYMap xyMap =
99 fl::u8 keep = 255 - blur_amount;
100 fl::u8 seep = blur_amount >> 1;
101 // blur rows
102 for (fl::u8 row = 0; row < height; ++row) {
103 CRGB carryover = CRGB::Black;
104 for (fl::u8 i = 0; i < width; ++i) {
105 CRGB cur = leds[xyMap.mapToIndex(i, row)];
106 CRGB part = cur;
107 part.nscale8(seep);
108 cur.nscale8(keep);
109 cur += carryover;
110 if (i)
111 leds[xyMap.mapToIndex(i - 1, row)] += part;
112 leds[xyMap.mapToIndex(i, row)] = cur;
113 carryover = part;
114 }
115 }
116 // blur columns
117 for (fl::u8 col = 0; col < width; ++col) {
118 CRGB carryover = CRGB::Black;
119 for (fl::u8 i = 0; i < height; ++i) {
120 CRGB cur = leds[xyMap.mapToIndex(col, i)];
121 CRGB part = cur;
122 part.nscale8(seep);
123 cur.nscale8(keep);
124 cur += carryover;
125 if (i)
126 leds[xyMap.mapToIndex(col, i - 1)] += part;
127 leds[xyMap.mapToIndex(col, i)] = cur;
128 carryover = part;
129 }
130 }
131}
fl::XYMap xyMap
fl::CRGB leds[NUM_LEDS]
static XYMap constructWithUserFunction(u16 width, u16 height, XYFunction xyFunction, u16 offset=0) FL_NOEXCEPT
Definition xymap.cpp.hpp:27
fl::CRGB CRGB
Definition crgb.h:25
unsigned char u8
Definition s16x16x4.h:132
unsigned char u8
Definition stdint.h:131
u8 u8 height
Definition blur.h:186
u8 u8 fract8 blur_amount
Definition blur.h:186
u8 width
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::XYMap::constructWithUserFunction(), fl::cur, fl::height, leds, fl::CRGB::nscale8(), fl::width, and xyMap.

+ Here is the call graph for this function: