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

Method fromXMap

src/fl/math/xymap.cpp.hpp:60–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58}
59
60XYMap XYMap::fromXMap(const XMap& xmap) {
61 // Create an XYMap with width=xmap.length and height=1
62 // This treats the 1D strip as a 2D grid with height 1
63 u16 length = xmap.getLength();
64
65 // Create a user function that dispatches to the XMap
66 // Since we can't capture xmap directly, we create a LUT and use that
67 auto out = XYMap::constructWithLookUpTable(length, 1, nullptr);
68 fl::shared_ptr<LUT16> lut = fl::make_shared<LUT16>(length);
69 u16* data = lut->getDataMutable();
70
71 // Fill the LUT with xmap's mappings
72 for (u16 i = 0; i < length; i++) {
73 data[i] = xmap.mapToIndex(i);
74 }
75
76 out.mLookUpTable = lut;
77 return out;
78}
79
80XYMap::XYMap(u16 width, u16 height, bool is_serpentine,
81 u16 offset)

Callers

nothing calls this directly

Calls 3

getDataMutableMethod · 0.80
getLengthMethod · 0.45
mapToIndexMethod · 0.45

Tested by

no test coverage detected