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

◆ at_splat_extrapolate()

Tile2x2_u8 fl::Corkscrew::at_splat_extrapolate ( float i) const
private

Definition at line 85 of file corkscrew.cpp.

85 {
86 // To finish this, we need to handle wrap around.
87 // To accomplish this we need a different data structure than the the
88 // Tile2x2_u8.
89 // 1. It will be called CorkscrewTile2x2_u8.
90 // 2. The four alpha values will each contain the index the LED is at,
91 // uint16_t.
92 // 3. There will be no origin, each pixel in the tile will contain a
93 // uint16_t origin. This is not supposed to be a storage format, but a
94 // convenient pre-computed value for rendering.
95 if (i >= mState.mapping.size()) {
96 // Handle out-of-bounds access, possibly by returning a default
97 // Tile2x2_u8
98 FASTLED_ASSERT(false, "Out of bounds access in Corkscrew at_splat: "
99 << i << " size: " << mState.mapping.size());
100 return Tile2x2_u8();
101 }
102 // Use the splat function to convert the vec2f to a Tile2x2_u8
103 float i_floor = floorf(i);
104 float i_ceil = ceilf(i);
105 if (ALMOST_EQUAL_FLOAT(i_floor, i_ceil)) {
106 // If the index is the same, just return the splat of that index
107 return splat(mState.mapping[static_cast<uint16_t>(i_floor)]);
108 } else {
109 // Interpolate between the two points and return the splat of the result
110 vec2f pos1 = mState.mapping[static_cast<uint16_t>(i_floor)];
111 vec2f pos2 = mState.mapping[static_cast<uint16_t>(i_ceil)];
112
113 if (pos2.x < pos1.x) {
114 // If the next point is on the other side of the cylinder, we need
115 // to wrap it around and bring it back into the positive direction so we can construct a Tile2x2_u8 wrap with it.
116 pos2.x += mState.width;
117 }
118
119 vec2f interpolated_pos =
120 pos1 * (1.0f - (i - i_floor)) + pos2 * (i - i_floor);
121 return splat(interpolated_pos);
122 }
123}
#define ALMOST_EQUAL_FLOAT(a, b)
Definition math_macros.h:37
Tile2x2_u8 splat(vec2f xy)
"Splat" as in "splat pixel rendering" takes a pixel value in float x,y coordinates and "splats" it in...
Definition splat.cpp:14
vec2< float > vec2f
Definition geometry.h:318

References ALMOST_EQUAL_FLOAT, mState, fl::splat(), and fl::vec2< T >::x.

Referenced by at_wrap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: