FastLED 3.10.6
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 67 of file xymap.cpp.hpp.

67 {
68 // Create an XYMap with width=xmap.length and height=1
69 // This treats the 1D strip as a 2D grid with height 1
70 u16 length = xmap.getLength();
71
72 // Null rather than a table: the LUT is allocated here and filled just
73 // below, which is what the null case in `constructWithLookUpTable`
74 // exists for.
75 auto out = XYMap::constructWithLookUpTable(length, 1, nullptr);
76 fl::shared_ptr<LUT16> lut = fl::make_shared<LUT16>(length);
77 u16* data = lut->getDataMutable();
78
79 // Fill the LUT with xmap's mappings
80 for (u16 i = 0; i < length; i++) {
81 data[i] = xmap.mapToIndex(i);
82 }
83
84 out.mLookUpTable = lut;
85 return out;
86}
static XYMap constructWithLookUpTable(u16 width, u16 height, const u16 *lookUpTable, u16 offset=0) FL_NO_EXCEPT
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_NO_EXCEPT
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: