‹ pakt18pakt20 ›

pakt19


pact19bubbles, 01:00, 1.84MB

Built with p5.js and SuperCollider. See /f0blog/pact-februari/

//pakt19
let index, n;
let speed, disorder, rad;
let bubbles= [];
let grad;
function setup() {
  let div= select('#sketch');
  let cnv= createCanvas(div.width, div.height);
  cnv.parent('sketch');
  frameRate(60);
  noStroke();
  index= 0;
  n= 200;
  rad= 25;
  for(let i= 0; i<n; i++) {
    bubbles[i]= [];
    bubbles[i][0]= 0;
    bubbles[i][1]= 0;
    bubbles[i][2]= 1;
  }
  grad= createGraphics(width, height);
  grad.noStroke();
  for(let r= width; r>0; --r) {
    grad.fill(lerpColor(color(255, 77, 77), color(0, 0, 0), r/width));
    grad.ellipse(width*0.5, height*0.5, r*2.0, r*2.0);
  }
}
function draw() {
  speed= sin(index*0.02)*0.01+0.065;
  disorder= sin(index*0.0022)*25+25;
  image(grad, 0, 0);
  translate(width*0.5, height*0.5);
  for (let i= 0; i<n; i++) {
    let b= bubbles[i];
    let theta= ((i/n)+sin(index*0.0001))*TWO_PI;
    fill(255, 255, 255, (1-b[2])*255);
    ellipse(
      sin(theta+((sin(index*0.0008)*0.25+1)*i))*width*0.4*b[0],
      cos(theta+((sin(index*0.0012)*0.25+1)*i))*height*0.4*b[1],
      rad*b[2]*2,
      rad*b[2]*2
      );
      let dxyz= (sin((index+(i*speed*disorder))*0.01)*0.1+0.15)*speed;
      bubbles[i][0]= (b[0]+dxyz)%1;
      bubbles[i][1]= (b[1]+dxyz)%1;
      bubbles[i][2]= (b[2]+dxyz)%1;
    }
    index++;
  }

Ndef(\bubbles).play
(
Ndef(\bubbles, {var n= 6;
    GVerb.ar(Mix({|i|
      var q= i/n*2pi;
      var t= Impulse.ar(SinOsc.ar(SinOsc.ar(0.125, q, 0.5), 0, 1.5, 2), i/n);
      Pan2.ar(
        SinOsc.ar(
          SinOsc.ar(0.01, q, SinOsc.ar(0.05, q, 50), 500),
          Decay2.ar(t, 0.02, 0.2, SinOsc.ar(0.05, q, SinOsc.ar(0.01, 0, 8pi, 8pi))),
          Decay2.ar(t, TRand.ar(0.003, 0.03, t), TRand.ar(0.05, 0.1, t), SinOsc.ar(0.08, q, 0.2, 0.05).max(0))
        ),
        (i/(n-1))*2-1
      );
    }!n), 40, 2, 0.6);
});
)
Ndef(\bubbles).stop