FastLED 3.10.6
Loading...
Searching...
No Matches

◆ mapToIndex() [1/2]

u16 fl::XYMap::mapToIndex ( const u16 & x,
const u16 & y ) const

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

124 {
125 u16 index;
126 switch (type) {
127 case kSerpentine: {
128 u16 xx = x % width;
129 u16 yy = y % height;
130 index = xy_serpentine(xx, yy, width, height);
131 break;
132 }
133 case kLineByLine: {
134 u16 xx = x % width;
135 u16 yy = y % height;
136 index = xy_line_by_line(xx, yy, width, height);
137 break;
138 }
139 case kFunction:
140 if (xyFunction) {
141 index = xyFunction(x, y, width, height);
142 } else {
143 // Null function pointer — fall back to line-by-line to avoid crash.
144 // This can happen due to cross-DLL static initialization order issues.
145 index = xy_line_by_line(x, y, width, height);
146 }
147 break;
148 case kLookUpTable:
149 index = mLookUpTable->getData()[y * width + x];
150 break;
151 default:
152 return 0;
153 }
154 return index + mOffset;
155}
XYFunction xyFunction
Definition xymap.h:130
u16 mOffset
Definition xymap.h:132
u16 width
Definition xymap.h:128
@ kSerpentine
Definition xymap.h:43
@ kFunction
Definition xymap.h:43
@ kLineByLine
Definition xymap.h:43
@ kLookUpTable
Definition xymap.h:43
u16 height
Definition xymap.h:129
fl::LUT16Ptr mLookUpTable
Definition xymap.h:131
XyMapType type
Definition xymap.h:127
FASTLED_FORCE_INLINE u16 xy_line_by_line(u16 x, u16 y, u16 width, u16 height) FL_NO_EXCEPT
Definition xymap.h:25
FASTLED_FORCE_INLINE u16 xy_serpentine(u16 x, u16 y, u16 width, u16 height) FL_NO_EXCEPT
Definition xymap.h:15

References height, kFunction, kLineByLine, kLookUpTable, kSerpentine, mLookUpTable, mOffset, type, width, fl::x, fl::xy_line_by_line(), fl::xy_serpentine(), xyFunction, and fl::y.

Referenced by convertToLookUpTable(), mapPixels(), mapToIndex(), operator()(), and toScreenMap().

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