FastLED 3.9.15
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 127 of file tile2x2.cpp.

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

References Tile2x2_u8_wrap(), at(), mData, pos, t, x, and y.

+ Here is the call graph for this function: