static int gardenPalette = 0, gardenSpeed = 1;
static uint32_t gardenLast = 0;
static float gardenPhase = 0;
void appSetup(){ gardenLast = Mio::elapsed(); }
void appLoop(){
  uint32_t now = Mio::elapsed();
  gardenPhase = fmodf(gardenPhase + (now - gardenLast) * 0.0005f * gardenSpeed, TWO_PI * 2);
  gardenLast = now;
  if (Mio::pressedA()) gardenPalette = (gardenPalette + 1) % 3;
  if (Mio::pressedB()) gardenSpeed = gardenSpeed % 3 + 1;
}
void appDraw(){
  auto &c = Mio::canvas;
  const uint16_t ink[] = {c.color565(253,115,69), c.color565(239,205,79), c.color565(104,204,177)};
  c.fillSprite(c.color565(23,31,40));
  for (int band = 0; band < 3; ++band) {
    int lastX = 0, lastY = 0;
    for (int step = 0; step <= 52; ++step) {
      float t = gardenPhase + band * 2.0f - (52 - step) * 0.035f;
      int x = 160 + 146 * sinf(t), y = 85 + 72 * sinf(1.5f * t + band);
      if (step) c.drawLine(lastX, lastY, x, y, ink[(gardenPalette + band) % 3]);
      lastX = x; lastY = y;
    }
    c.fillCircle(lastX, lastY, 4, ink[(gardenPalette + band) % 3]);
  }
}
