Auf beliebigen Matrizen nutzbar

This commit is contained in:
starcalc 2018-02-11 19:04:02 +01:00
parent 52ccd0c31d
commit 2230525e17
1 changed files with 4 additions and 4 deletions

View File

@ -778,16 +778,16 @@ uint32_t NeoPatterns::Wheel(byte WheelPos)
// Convert x y pixel position to matrix position
uint8_t NeoPatterns::xyToPos(int x, int y) {
if (y % 2 == 0) {
return (y * 8 + x);
return (y * (int)sqrt(numPixels()) + x);
} else {
return (y * 8 + (7 - x));
return (y * (int)sqrt(numPixels()) + (((int)sqrt(numPixels())-1) - x));
}
}
//convert pixel number to actual 8x8 matrix position
uint8_t NeoPatterns::numToPos(int num) {
int x = num % 8;
int y = num / 8;
int x = num % (int)sqrt(numPixels());
int y = num / (int)sqrt(numPixels());
return xyToPos(x, y);
}