#include <Adafruit_ILI9341.h>
//что такое sinf     2.f и 127.5f      2.0 is double ; 2.0f is float    БЕССМЫСЛ
#define TFT_CS   9
#define TFT_DC   10
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);

#define WIDTH 320
#define HEIGHT 240

uint8_t sinus[1024];

void setup() {   tft.begin();
  tft.setRotation(1);
  for (int i = 0; i < 1024; i++)
    sinus[i] = 127.5f + 127.5f * sinf(i * 2.f * 3.1415927f / 1024.f);
}

void loop() {
  uint16_t line_buffer[WIDTH];
  uint16_t scale[6], accu[6];
  for (byte i = 0; i < 6; i++) {
    scale[i] = rand() >> 6;
    if (rand() < RAND_MAX / 2)
      scale[i] = -scale[i];
    accu[i] = rand();
  }

  for (uint16_t y = 0; y < HEIGHT; y++) {
    for (byte i = 0; i < 3; i++) {
      accu[i] += scale[i];
      accu[i+3] = accu[i];
    }
    uint16_t *line = line_buffer;

    for (uint16_t x = 0; x < WIDTH; x++) {
      for (byte i = 3; i < 6; i++)
        accu[i] += scale[i];
      uint8_t r, g, b;
      r = sinus[((accu[3] + 20 * sinus[((accu[0] + x * 3 - y * 5) >> 4) % 1024]) >> 6) % 1024] >> 3;
      g = sinus[((accu[4] + 24 * sinus[((accu[1] - x * 6 + y * 7) >> 4) % 1024]) >> 6) % 1024] >> 2;
      b = sinus[((accu[5] + 18 * sinus[((accu[2] + x * 7 - y * 3) >> 4) % 1024]) >> 6) % 1024] >> 3;
      uint16_t rgb565 = b | (g << 5) | (r << 11);
      *line++ = rgb565;
    }
    tft.drawRGBBitmap(0, y, line_buffer, WIDTH, 1);
  }
}