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

◆ blurRows() [3/3]

void fl::gfx::blurRows ( fl::span< CRGB > leds,
u8 width,
u8 height,
fract8 blur_amount,
const XYMap & xymap )

Perform a blur1d() on every row of a rectangular matrix (span version).

See also
blur1d()
Parameters
ledsspan of LEDs to blur
widththe width of the matrix
heightthe height of the matrix
blur_amountthe amount of blur to apply

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

134 {
135 CRGB *pixels = leds.data();
136 fl::u8 keep = 255 - blur_amount;
137 fl::u8 seep = blur_amount >> 1;
138 if (xyMap.isRectangularGrid()) {
139 for (fl::u8 row = 0; row < height; ++row) {
140 CRGB carryover = CRGB::Black;
141 CRGB *rowBase = pixels + row * width;
142 for (fl::u8 col = 0; col < width; ++col) {
143 CRGB cur = rowBase[col];
144 CRGB part = cur;
145 part.nscale8(seep);
146 cur.nscale8(keep);
147 cur += carryover;
148 if (col)
149 rowBase[col - 1] += part;
150 rowBase[col] = cur;
151 carryover = part;
152 }
153 }
154 return;
155 }
156 for (fl::u8 row = 0; row < height; ++row) {
157 CRGB carryover = CRGB::Black;
158 for (fl::u8 i = 0; i < width; ++i) {
159 CRGB cur = leds[xyMap.mapToIndex(i, row)];
160 CRGB part = cur;
161 part.nscale8(seep);
162 cur.nscale8(keep);
163 cur += carryover;
164 if (i)
165 leds[xyMap.mapToIndex(i - 1, row)] += part;
166 leds[xyMap.mapToIndex(i, row)] = cur;
167 carryover = part;
168 }
169 }
170}
fl::XYMap xyMap
fl::CRGB leds[NUM_LEDS]
u16 mapToIndex(const u16 &x, const u16 &y) const FL_NOEXCEPT
unsigned char u8
Definition s16x16x4.h:132
fl::CRGB CRGB
Definition video.h:15
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::cur, fl::height, leds, fl::CRGB::nscale8(), fl::width, and xyMap.

Referenced by blur2d(), blur2d(), fl::blurRows(), fl::blurRows(), fl::blurRows(), and blurRows().

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