9#define TWO_PI (PI * 2.0)
34 const float width_step =
36 const float height_step =
42 for (uint16_t i = 0; i < input.
numLeds; ++i) {
44 const float i_f =
static_cast<float>(i);
45 const float alpha_width = i_f * width_step;
46 const float alpha_height = i_f * height_step;
47 const float width_before_mod = alpha_width * input.
totalLength;
48 const float height = alpha_height * input.
totalHeight;
49 const float width = fmodf(width_before_mod, length_per_turn);
50 output->
mapping.push_back({width, height});
54 float max_width = 0.0f;
55 float max_height = 0.0f;
56 for (
const auto &point : output->
mapping) {
57 max_width =
MAX(max_width, point.x);
58 max_height =
MAX(max_height, point.y);
60 output->
width =
static_cast<uint16_t
>(ceilf(max_width)) + 1;
61 output->
height =
static_cast<uint16_t
>(ceilf(max_height)) + 1;
75 if (i >=
mState.mapping.size()) {
95 if (i >=
mState.mapping.size()) {
98 FASTLED_ASSERT(
false,
"Out of bounds access in Corkscrew at_splat: "
99 << i <<
" size: " <<
mState.mapping.size());
103 float i_floor = floorf(i);
104 float i_ceil = ceilf(i);
107 return splat(
mState.mapping[
static_cast<uint16_t
>(i_floor)]);
110 vec2f pos1 =
mState.mapping[
static_cast<uint16_t
>(i_floor)];
111 vec2f pos2 =
mState.mapping[
static_cast<uint16_t
>(i_ceil)];
113 if (pos2.
x < pos1.
x) {
119 vec2f interpolated_pos =
120 pos1 * (1.0f - (i - i_floor)) + pos2 * (i - i_floor);
121 return splat(interpolated_pos);
Tile2x2_u8 at_splat_extrapolate(float i) const
vec2f at_exact(uint16_t i) const
Tile2x2_u8_wrap at_wrap(float i) const
Corkscrew(const Input &input)
static State generateState(const Input &input)
For testing.
#define ALMOST_EQUAL_FLOAT(a, b)
Tile2x2_u8 splat(vec2f xy)
"Splat" as in "splat pixel rendering" takes a pixel value in float x,y coordinates and "splats" it in...
void generateState(const Corkscrew::Input &input, CorkscrewState *output)
void reverse(Iterator first, Iterator last)
Implements a simple red square effect for 2D LED grids.
Corkscrew projection utilities.
fl::vector< fl::vec2f, fl::allocator_psram< fl::vec2f > > mapping