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

◆ bilinearInterpolateFloat()

uint8_t fl::bilinearInterpolateFloat ( uint8_t v00,
uint8_t v10,
uint8_t v01,
uint8_t v11,
float dx,
float dy )

Definition at line 159 of file bilinear_expansion.cpp.

160 {
161 float dx_inv = 1.0f - dx;
162 float dy_inv = 1.0f - dy;
163
164 // Calculate the weights for each corner
165 float w00 = dx_inv * dy_inv;
166 float w10 = dx * dy_inv;
167 float w01 = dx_inv * dy;
168 float w11 = dx * dy;
169
170 // Compute the weighted sum
171 float sum = v00 * w00 + v10 * w10 + v01 * w01 + v11 * w11;
172
173 // Clamp the result to [0, 255] and round
174 uint8_t result = static_cast<uint8_t>(sum + 0.5f);
175
176 return result;
177}

Referenced by bilinearExpandArbitraryFloat(), and bilinearExpandFloat().

+ Here is the caller graph for this function: