Merge branch '3-plasma-und-larson-spiral-verwenden-zwei-boxen-nicht' into 'master'

Resolve "Plasma und Larson Spiral verwenden zwei Boxen nicht."

Closes #3

See merge request ctdo/esp-videoswitcher!2
This commit is contained in:
starcalc 2018-02-11 19:08:01 +01:00
commit f50590a28e
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);
}