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 131 of file FxWater.ino.

131 {
132 // extract the fractional parts and derive their inverses
133 uint8_t xx = x & 0xff, yy = y & 0xff, ix = 255 - xx, iy = 255 - yy;
134 // calculate the intensities for each affected pixel
135 #define WU_WEIGHT(a, b) ((uint8_t)(((a) * (b) + (a) + (b)) >> 8))
136 uint8_t wu[4] = {WU_WEIGHT(ix, iy), WU_WEIGHT(xx, iy),
137 WU_WEIGHT(ix, yy), WU_WEIGHT(xx, yy)
138 };
139 #undef WU_WEIGHT
140 // multiply the intensities by the colour, and saturating-add them to the pixels
141 for (uint8_t i = 0; i < 4; i++) {
142 uint8_t local_x = (x >> 8) + (i & 1);
143 uint8_t local_y = (y >> 8) + ((i >> 1) & 1);
144 uint16_t xy = WATERWIDTH * local_y + local_x;
145 if (xy >= WATERWIDTH * WATERHEIGHT) continue;
146 uint16_t this_bright = bright * wu[i];
147 buf[xy] = qadd8(buf[xy], this_bright >> 8);
148 }
149}
uint32_t x[NUM_LAYERS]
Definition Fire2023.ino:80
uint32_t y[NUM_LAYERS]
Definition Fire2023.ino:81
#define WATERHEIGHT
Definition FxWater.ino:18
#define WU_WEIGHT(a, b)
#define WATERWIDTH
Definition FxWater.ino:17
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:31

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: