FastLED 3.10.8
Loading...
Searching...
No Matches

◆ mapToIndex() [1/2]

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

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

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