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

◆ fromXMap()

XYMap fl::XYMap::fromXMap ( const XMap & xmap)
static

Create an XYMap from an XMap (treats 1D as 2D with height=1)

Parameters
xmap1D addressing map
Returns
XYMap with width=xmap.length and height=1

Definition at line 60 of file xymap.cpp.hpp.

60 {
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}
static XYMap constructWithLookUpTable(u16 width, u16 height, const u16 *lookUpTable, u16 offset=0) FL_NOEXCEPT
Definition xymap.cpp.hpp:42
fl::UISlider length("Length", 1.0f, 0.0f, 1.0f, 0.01f)
shared_ptr< T > make_shared(Args &&... args) FL_NOEXCEPT
Definition shared_ptr.h:414

References XYMap(), constructWithLookUpTable(), fl::XMap::getLength(), length(), fl::make_shared(), and fl::XMap::mapToIndex().

Referenced by fl::Channel::setScreenMap().

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