// Feuilles vivantes
// Par PLN
// Basé sur une photo de Chris Lawton : https://unsplash.com/photos/5IHz5WhosQE
//
// Pour Pierre

a.show()
a.setBins(4)

s0.initImage("https://images.unsplash.com/photo-1477414348463-c0eb7f1359b6?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2670&q=80")

src(s0)
.scrollX(1, 0.0333)
.scrollY(() => a.fft[0] * 0.1, 0.1)
.modulateRotate(noise(() => Math.sin(time / 4) * 10 + 20), () => Math.sin(time / 5.33) / 2 + 0.5)
.kaleid(2)
.out(o0)

src(o0)
  .scale(0.99)
  .out(o1)

src(o1)
  .scale(1.0009)
  .modulateRotate(src(o1), 0.5)
  .mult(src(o2).rotate(0.5), 0.7)
  .out(o2)

src(o2)
.scale(() => 1.05 + 0.2 * Math.sin(time / 10))
// .luma(() => 0.1 + 0.7 * (Math.sin(time /100)))
.blend(src(o2)
  .scale(() => 0.4 + 0.05 * Math.sin(time / 10))
  , 0.2)
  .invert(() => Math.sin(time / 1))
.out(o3)

render(o1)