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

◆ mapToIndex() [1/2]

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

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

116 {
117 u16 index;
118 switch (type) {
119 case kSerpentine: {
120 u16 xx = x % width;
121 u16 yy = y % height;
122 index = xy_serpentine(xx, yy, width, height);
123 break;
124 }
125 case kLineByLine: {
126 u16 xx = x % width;
127 u16 yy = y % height;
128 index = xy_line_by_line(xx, yy, width, height);
129 break;
130 }
131 case kFunction:
132 if (xyFunction) {
133 index = xyFunction(x, y, width, height);
134 } else {
135 // Null function pointer — fall back to line-by-line to avoid crash.
136 // This can happen due to cross-DLL static initialization order issues.
137 index = xy_line_by_line(x, y, width, height);
138 }
139 break;
140 case kLookUpTable:
141 index = mLookUpTable->getData()[y * width + x];
142 break;
143 default:
144 return 0;
145 }
146 return index + mOffset;
147}
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_NOEXCEPT
Definition xymap.h:25
FASTLED_FORCE_INLINE u16 xy_serpentine(u16 x, u16 y, u16 width, u16 height) FL_NOEXCEPT
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 fl::anonymous_namespace{channel.cpp.hpp}::ReorderingPixelIteratorAny::ReorderingPixelIteratorAny(), convertToLookUpTable(), mapPixels(), mapToIndex(), operator()(), and toScreenMap().

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