FastLED 3.10.8
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 94 of file blur.cpp.hpp.

94 {
95 // Legacy path: uses global XY() via XYMap for user-defined layouts.
96 // Keeps its own blur algorithm copy because XYMap indexing differs from
97 // the cache-coherent rectangular layout used by Canvas.
98 XYMap xyMap =
100 fl::u8 keep = 255 - blur_amount;
101 fl::u8 seep = blur_amount >> 1;
102 // blur rows
103 for (fl::u8 row = 0; row < height; ++row) {
104 CRGB carryover = CRGB::Black;
105 for (fl::u8 i = 0; i < width; ++i) {
106 CRGB cur = leds[xyMap.mapToIndex(i, row)];
107 CRGB part = cur;
108 part.nscale8(seep);
109 cur.nscale8(keep);
110 cur += carryover;
111 if (i)
112 leds[xyMap.mapToIndex(i - 1, row)] += part;
113 leds[xyMap.mapToIndex(i, row)] = cur;
114 carryover = part;
115 }
116 }
117 // blur columns
118 for (fl::u8 col = 0; col < width; ++col) {
119 CRGB carryover = CRGB::Black;
120 for (fl::u8 i = 0; i < height; ++i) {
121 CRGB cur = leds[xyMap.mapToIndex(col, i)];
122 CRGB part = cur;
123 part.nscale8(seep);
124 cur.nscale8(keep);
125 cur += carryover;
126 if (i)
127 leds[xyMap.mapToIndex(col, i - 1)] += part;
128 leds[xyMap.mapToIndex(col, i)] = cur;
129 carryover = part;
130 }
131 }
132}
CRGB leds[1]
fl::XYMap xyMap
static XYMap constructWithUserFunction(u16 width, u16 height, XYFunction xyFunction, u16 offset=0) FL_NO_EXCEPT
Definition xymap.cpp.hpp:28
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 width
Definition blur.h:186
CRGB & nscale8(u8 scaledown) FL_NO_EXCEPT
Scale down a RGB to N/256ths of its current brightness, using "plain math" dimming rules.
Definition crgb.cpp.hpp:87
@ Black
<div style='background:#000000;width:4em;height:4em;'></div>
Definition crgb.h:517
Representation of an 8-bit RGB pixel (Red, Green, Blue)
Definition crgb.h:38

References fl::CRGB::Black, fl::XYMap::constructWithUserFunction(), fl::cur, fl::FL_NO_EXCEPT, fl::height, leds, fl::CRGB::nscale8(), fl::width, and xyMap.

+ Here is the call graph for this function: