Browse Source

Auf beliebigen Matrizen nutzbar

3-plasma-und-larson-spiral-verwenden-zwei-boxen-nicht
starcalc 4 years ago
parent
commit
2230525e17
  1. 8
      NeoPatterns.cpp

8
NeoPatterns.cpp

@ -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);
}

Loading…
Cancel
Save