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

Method calculateTileAtWrap

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

Source from the content-addressed store, hash-verified

175}
176
177Tile2x2_u8_wrap Corkscrew::calculateTileAtWrap(float i) const {
178 // This is a splatted pixel, but wrapped around the cylinder.
179 // This is useful for rendering the corkscrew in a cylindrical way.
180 Tile2x2_u8 tile = at_splat_extrapolate(i);
181 Tile2x2_u8_wrap::Entry data[2][2];
182 vec2<u16> origin = tile.origin();
183 for (fl::u8 x = 0; x < 2; x++) {
184 for (fl::u8 y = 0; y < 2; y++) {
185 // For each pixel in the tile, map it to the cylinder so that each subcomponent
186 // is mapped to the correct position on the cylinder.
187 vec2<u16> pos = origin + vec2<u16>(x, y);
188 // now wrap the x-position
189 pos.x = fl::fmodf(pos.x, static_cast<float>(mWidth));
190 data[x][y] = {pos, tile.at(x, y)};
191 }
192 }
193 return Tile2x2_u8_wrap(data);
194}
195
196void Corkscrew::setCachingEnabled(bool enabled) {
197 if (!enabled && mCachingEnabled) {

Callers

nothing calls this directly

Calls 4

fmodfFunction · 0.85
originMethod · 0.80
Tile2x2_u8_wrapClass · 0.70
atMethod · 0.45

Tested by

no test coverage detected