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 140 of file FxWater.h.

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

References 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: