MCPcopy Create free account
hub / github.com/FastLED/FastLED / at_splat_extrapolate

Method at_splat_extrapolate

src/fl/gfx/corkscrew.cpp.hpp:132–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130
131
132Tile2x2_u8 Corkscrew::at_splat_extrapolate(float i) const {
133 if (i >= mNumLeds) {
134 // Handle out-of-bounds access, possibly by returning a default
135 // Tile2x2_u8
136 FASTLED_ASSERT(false, "Out of bounds access in Corkscrew at_splat: "
137 << i << " size: " << mNumLeds);
138 return Tile2x2_u8();
139 }
140
141 // Use the splat function to convert the vec2f to a Tile2x2_u8
142 float i_floor = fl::floorf(i);
143 float i_ceil = fl::ceilf(i);
144 if (fl::almost_equal(i_floor, i_ceil)) {
145 // If the index is the same, just return the splat of that index
146 vec2f position = at_no_wrap(static_cast<fl::u16>(i_floor));
147 return splat(position);
148 } else {
149 // Interpolate between the two points and return the splat of the result
150 vec2f pos1 = at_no_wrap(static_cast<fl::u16>(i_floor));
151 vec2f pos2 = at_no_wrap(static_cast<fl::u16>(i_ceil));
152 float t = i - i_floor;
153 vec2f interpolated_pos = map_range(t, 0.0f, 1.0f, pos1, pos2);
154 return splat(interpolated_pos);
155 }
156}
157
158fl::size Corkscrew::size() const { return mNumLeds; }
159

Callers

nothing calls this directly

Calls 5

floorfFunction · 0.85
ceilfFunction · 0.85
almost_equalFunction · 0.85
splatFunction · 0.85
Tile2x2_u8Class · 0.70

Tested by

no test coverage detected