int XYsafe(int x, int y) { if ( x >= LED_WIDTH) return 0; if ( y >= LED_HEIGHT) return 0; if ( x < 0) return 0; if ( y < 0) return 0; // Invert y y = LED_HEIGHT - 1 - y; if (y & 1) x = LED_WIDTH - 1 - x; // Invert x //x = LED_WIDTH - 1 - x; return y*LED_WIDTH+x; } void setPixel(int x, int y, CRGB color) { if ( x >= LED_WIDTH) return; if ( y >= LED_HEIGHT) return; if ( x < 0) return; if ( y < 0) return; // Invert y y = LED_HEIGHT - 1 - y; if (y & 1) x = LED_WIDTH - 1 - x; // Invert x //x = LED_WIDTH - 1 - x; leds[y*LED_WIDTH+x] = color; } void setPixel(int i, CRGB color) { int x = i % LED_WIDTH; int y = i / LED_WIDTH; setPixel(x, y, color); } void setPixel(Window win, int x, int y, CRGB color) { if (x >= win.w || y >= win.h || x < 0 || y < 0) return; setPixel(win.x + x, win.y + y, color); } void clear(Window window, CRGB color) { for ( byte y = 0; y < window.h; y++) { for ( byte x = 0; x < window.w; x++) { setPixel(window, x, y, color); } } } void clear(Window window) { clear(window, CRGB(0)); } void clear() { Window w = {0, 0, LED_WIDTH, LED_HEIGHT}; clear(w); } inline double sines(double x, double y) { return ((cos(x) * sin(y)) * 0.5) + 0.5; } inline double basefield(double x, double y) { return (cos(x) * sin(y) * cos(sqrt((x*x) + (y*y)))); } inline double addmod(double x, double mod, double delta) { x = x + delta; while( x >= mod ) x -= mod; while( x < 0.0 ) x += mod; return x; } inline double addmodpi(double x, double delta) { return addmod(x, 2*PI, delta); }