10XMap XMap::constructWithUserFunction(uint16_t length, XFunction xFunction, uint16_t offset) {
11 XMap out = XMap(length, kFunction);
12 out.xFunction = xFunction;
19XMap XMap::constructWithLookUpTable(uint16_t length,
const uint16_t *lookUpTable, uint16_t offset) {
20 XMap out = XMap(length, kLookUpTable);
21 out.mData = lookUpTable;
28XMap::XMap(uint16_t length,
bool is_reverse, uint16_t offset) {
29 type = is_reverse ? kReverse : kLinear;
30 this->length = length;
31 this->mOffset = offset;
36XMap::XMap(
const XMap &other) {
38 length = other.length;
39 xFunction = other.xFunction;
41 mLookUpTable = other.mLookUpTable;
42 mOffset = other.mOffset;
47void XMap::convertToLookUpTable() {
48 if (type == kLookUpTable) {
52 mLookUpTable = LUT16Ptr::New(length);
53 uint16_t* dataMutable = mLookUpTable->getData();
54 mData = mLookUpTable->getData();
55 for (uint16_t x = 0; x < length; x++) {
56 dataMutable[x] = mapToIndex(x);
64uint16_t XMap::mapToIndex(uint16_t x)
const {
68 index = x_linear(x, length);
71 index = x_reverse(x, length);
75 index = xFunction(x, length);
83 return index + mOffset;
88uint16_t XMap::getLength()
const {
94XMap::Type XMap::getType()
const {
100XMap::XMap(uint16_t length, Type type)
101 : length(length), type(type), mOffset(0) {
106XMap &XMap::operator=(
const XMap &other) {
107 if (
this != &other) {
109 length = other.length;
110 xFunction = other.xFunction;
112 mLookUpTable = other.mLookUpTable;
113 mOffset = other.mOffset;
Implements a simple red square effect for 2D LED grids.