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

◆ upscaleFloat() [2/2]

u8 fl::upscaleFloat ( u8 v00,
u8 v10,
u8 v01,
u8 v11,
float dx,
float dy )

Definition at line 245 of file upscale.cpp.hpp.

246 {
247 float dx_inv = 1.0f - dx;
248 float dy_inv = 1.0f - dy;
249
250 // Calculate the weights for each corner
251 float w00 = dx_inv * dy_inv;
252 float w10 = dx * dy_inv;
253 float w01 = dx_inv * dy;
254 float w11 = dx * dy;
255
256 // Compute the weighted sum
257 float sum = v00 * w00 + v10 * w10 + v01 * w01 + v11 * w11;
258
259 // Clamp the result to [0, 255] and round
260 u8 result = static_cast<u8>(sum + 0.5f);
261
262 return result;
263}
unsigned char u8
Definition stdint.h:131
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31

Referenced by fl::ScaleUp::expand(), upscaleArbitraryFloat(), and upscaleFloat().

+ Here is the caller graph for this function: