// https://www.reddit.com/r/FastLED/comments/14u7t7i/led_trasition_gets_skipped_overflow/

#include <FastLED.h>

#define LED_PIN 2
#define NUM_LEDS 64

CRGB leds[NUM_LEDS];

//array
unsigned long int x[NUM_LEDS];
unsigned long int y[NUM_LEDS];

//palett
DEFINE_GRADIENT_PALETTE(indigoGP) {
  0, 0, 0, 0,
  100, 0, 0, 5,
  255, 191, 127, 247
};

CRGBPalette16 indigoPalett = indigoGP;


void setup() {
  Serial.begin(2000000);
  FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
  for (unsigned short i = 0; i < NUM_LEDS; i++) {
    unsigned char angle = (i * 256) / NUM_LEDS;
    x[i] = cos8(angle);
    y[i] = sin8(angle);
  }
}

void loop() {
  effect();
  FastLED.show();
}


//effect function (gets called in loop)
void effect() {
  uint8_t scale = 150;
  uint16_t shift_x = millis() / 40;
  uint16_t shift_y = millis() / 40;
  for (uint16_t i = 0; i < NUM_LEDS; i++) {

    uint32_t real_x = (x[i] + shift_x) * scale;
    uint32_t real_y = (y[i] + shift_y) * scale;

    uint8_t noise = inoise16(real_x, real_y, 4223) >> 8;
    uint8_t index = noise * 3;

    leds[i] = ColorFromPalette(indigoPalett, index);
  }
}