//
//Stepko

#include "FastLED.h"

// Matrix size
#define WIDTH 16
#define HEIGHT 16
#define NUM_LEDS HEIGHT * WIDTH
// LEDs pin
#define DATA_PIN 3
// LED brightness
#define BRIGHTNESS 255
// Define the array of leds
CRGB leds[NUM_LEDS];

void setup() {
  FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
  FastLED.setBrightness(BRIGHTNESS);
}
byte dir = 3;
void loop() {
  switch (dir) {
    case 0:
      for (byte x = 0; x < WIDTH - 1; x++) {
        for (byte y = 0; y < HEIGHT - 1; y++) {
          leds[XY(x, y)] = leds[XY(x, y + 1)];
        }
      } for (byte i = 0; i < 8; i++)leds[XY(beatsin8(12 + i, 0, WIDTH - 1), beatsin8(15 + i, HEIGHT / 2, HEIGHT - 1))] = CHSV(beatsin8(12 + i, 0, 255), 255, 255);
      break;
    case 1:
      for (byte x = 0; x < WIDTH - 1; x++) {
        for (byte y = HEIGHT - 1; y > 0; y--) {
          leds[XY(x, y)] = leds[XY(x, y - 1)];
        }
      } for (byte i = 0; i < 8; i++)leds[XY(beatsin8(12 + i, 0, WIDTH - 1), beatsin8(15 + i, 0, HEIGHT / 2))] = CHSV(beatsin8(12 + i, 0, 255), 255, 255);
      break;
    case 2:
      for (byte x = 0; x < WIDTH - 1; x++) {
        for (byte y = HEIGHT - 1; y > 0; y--) {
          leds[XY(x, y)] = leds[XY(x + 1, y)];
        }
      } for (byte i = 0; i < 8; i++)leds[XY(beatsin8(15 + i, WIDTH / 2, WIDTH - 1), beatsin8(12 + i, 0, HEIGHT - 1))] = CHSV(beatsin8(12 + i, 0, 255), 255, 255);
      break;
    case 3:
      for (byte x = WIDTH - 1; x > 0 ; x--) {
        for (byte y = HEIGHT - 1; y > 0; y--) {
          leds[XY(x, y)] = leds[XY(x - 1, y)];
        }
      } for (byte i = 0; i < 8; i++)leds[XY(beatsin8(15 + i, 0, WIDTH / 2), beatsin8(12 + i, 0, HEIGHT - 1))] = CHSV(beatsin8(12 + i, 0, 255), 255, 255);
      break;
  }
  blur2d(leds, WIDTH, HEIGHT, 32);
  FastLED.show();
} //loop


uint16_t XY (uint8_t x, uint8_t y) {
  return (y * WIDTH + x);
}