Auf beliebigen Matrizen nutzbar
This commit is contained in:
parent
52ccd0c31d
commit
2230525e17
|
@ -778,16 +778,16 @@ uint32_t NeoPatterns::Wheel(byte WheelPos)
|
||||||
// Convert x y pixel position to matrix position
|
// Convert x y pixel position to matrix position
|
||||||
uint8_t NeoPatterns::xyToPos(int x, int y) {
|
uint8_t NeoPatterns::xyToPos(int x, int y) {
|
||||||
if (y % 2 == 0) {
|
if (y % 2 == 0) {
|
||||||
return (y * 8 + x);
|
return (y * (int)sqrt(numPixels()) + x);
|
||||||
} else {
|
} else {
|
||||||
return (y * 8 + (7 - x));
|
return (y * (int)sqrt(numPixels()) + (((int)sqrt(numPixels())-1) - x));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//convert pixel number to actual 8x8 matrix position
|
//convert pixel number to actual 8x8 matrix position
|
||||||
uint8_t NeoPatterns::numToPos(int num) {
|
uint8_t NeoPatterns::numToPos(int num) {
|
||||||
int x = num % 8;
|
int x = num % (int)sqrt(numPixels());
|
||||||
int y = num / 8;
|
int y = num / (int)sqrt(numPixels());
|
||||||
return xyToPos(x, y);
|
return xyToPos(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue