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

◆ wu_water()

void wu_water ( uint8_t *const buf,
uint16_t x,
uint16_t y,
uint8_t bright )

Definition at line 141 of file FxWater.h.

141 {
142 // extract the fractional parts and derive their inverses
143 uint8_t xx = x & 0xff, yy = y & 0xff, ix = 255 - xx, iy = 255 - yy;
144 // calculate the intensities for each affected pixel
145 #define WU_WEIGHT(a, b) ((uint8_t)(((a) * (b) + (a) + (b)) >> 8))
146 uint8_t wu[4] = {WU_WEIGHT(ix, iy), WU_WEIGHT(xx, iy),
147 WU_WEIGHT(ix, yy), WU_WEIGHT(xx, yy)
148 };
149 #undef WU_WEIGHT
150 // multiply the intensities by the colour, and saturating-add them to the pixels
151 for (uint8_t i = 0; i < 4; i++) {
152 uint8_t local_x = (x >> 8) + (i & 1);
153 uint8_t local_y = (y >> 8) + ((i >> 1) & 1);
154 uint16_t xy = WATERWIDTH * local_y + local_x;
155 if (xy >= WATERWIDTH * WATERHEIGHT) continue;
156 uint16_t this_bright = bright * wu[i];
157 buf[xy] = qadd8(buf[xy], this_bright >> 8);
158 }
159}
int y
Definition simple.h:93
int x
Definition simple.h:92
#define WATERHEIGHT
Definition FxWater.h:28
#define WU_WEIGHT(a, b)
#define WATERWIDTH
Definition FxWater.h:27
unsigned int xy(unsigned int x, unsigned int y)
LIB8STATIC_ALWAYS_INLINE uint8_t qadd8(uint8_t i, uint8_t j)
Add one byte to another, saturating at 0xFF.
Definition math8.h:40

References qadd8(), WATERHEIGHT, WATERWIDTH, WU_WEIGHT, x, xy(), and y.

Referenced by loop().

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