FastLED 3.10.8
Loading...
Searching...
No Matches

◆ Interpolate()

fl::vector_fixed< Tile2x2_u8_wrap, 2 > fl::Tile2x2_u8_wrap::Interpolate ( const Tile2x2_u8_wrap & a,
const Tile2x2_u8_wrap & b,
float t )
static

Definition at line 128 of file tile2x2.cpp.hpp.

128 {
130
131 // Clamp t to [0, 1]
132 if (t <= 0.0f) {
133 result.push_back(a);
134 return result;
135 }
136 if (t >= 1.0f) {
137 result.push_back(b);
138 return result;
139 }
140
141 // Create interpolated tile
142 Tile2x2_u8_wrap interpolated;
143
144 // Interpolate each of the 4 positions
145 for (u16 x = 0; x < 2; ++x) {
146 for (u16 y = 0; y < 2; ++y) {
147 const auto& data_a = a.at(x, y);
148 const auto& data_b = b.at(x, y);
149
150 // For now, assume positions are the same or close enough
151 // Use position from 'a' as the base
152 vec2<u16> pos = data_a.first;
153
154 // Simple linear interpolation for alpha values
155 u8 alpha_a = data_a.second;
156 u8 alpha_b = data_b.second;
157
158 // Linear interpolation: a + t * (b - a)
159 float alpha_float = alpha_a + t * (alpha_b - alpha_a);
160 u8 interpolated_alpha = static_cast<u8>(alpha_float + 0.5f); // Round to nearest
161
162 interpolated.mData[y][x] = {pos, interpolated_alpha};
163 }
164 }
165
166 result.push_back(interpolated);
167 return result;
168}
uint8_t pos
Definition Blur.ino:11
Tile2x2_u8_wrap() FL_NO_EXCEPT
unsigned char u8
Definition stdint.h:131
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31
FixedVector< T, INLINED_SIZE > vector_fixed
Definition vector.h:1134

References Tile2x2_u8_wrap(), fl::FL_NO_EXCEPT, mData, pos, fl::t, fl::x, and fl::y.

+ Here is the call graph for this function: