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 161 of file bilinear_expansion.cpp.

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

Referenced by bilinearExpandArbitraryFloat(), and bilinearExpandFloat().

+ Here is the caller graph for this function: