FastLED 3.10.8
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 68 of file xymap.cpp.hpp.

68 {
69 // Create an XYMap with width=xmap.length and height=1
70 // This treats the 1D strip as a 2D grid with height 1
71 u16 length = xmap.getLength();
72
73 // Null rather than a table: the LUT is allocated here and filled just
74 // below, which is what the null case in `constructWithLookUpTable`
75 // exists for.
76 auto out = XYMap::constructWithLookUpTable(length, 1, nullptr);
77 fl::shared_ptr<LUT16> lut = fl::make_shared<LUT16>(length);
78 u16* data = lut->getDataMutable();
79
80 // Fill the LUT with xmap's mappings
81 for (u16 i = 0; i < length; i++) {
82 data[i] = xmap.mapToIndex(i);
83 }
84
85 out.mLookUpTable = lut;
86 return out;
87}
static XYMap constructWithLookUpTable(u16 width, u16 height, const u16 *lookUpTable, u16 offset=0) FL_NO_EXCEPT
Definition xymap.cpp.hpp:43
fl::UISlider length("Length", 1.0f, 0.0f, 1.0f, 0.01f)
shared_ptr< T > make_shared(Args &&... args) FL_NO_EXCEPT
Definition shared_ptr.h:423

References XYMap(), constructWithLookUpTable(), fl::FL_NO_EXCEPT, length(), and fl::adl_barrier::make_shared().

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

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