‹ pakt22pakt24 ›

pakt23


pact23sway, 01:00, 1.84MB

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

//pakt23
//ok - patterns not exactly the same, line width
let index;
let w, h;
let n;
function setup() {
  let div= select('#sketch');
  let cnv= createCanvas(div.width, div.height);
  cnv.parent('sketch');
  noStroke();
  background(150);
  strokeWeight(0.1);
  index= 0;
  w= width;
  h= height;
  n= 250;
}
function draw() {
  let rx= sin(index*0.0024);
  let ry= sin(index*0.0022+1);
  let tx= sin(index*0.0016+2)+rx;
  let ty= sin(index*0.0018+3)+ry;
  fill(color(255, 255, 255, 5));
  rect(0, 0, width, height);
  let x= 0.5*w, y= 0.5*h;
  for(let i= 50; i<n; i++) {
    let t= i/n;
    if(i==50) {
      x= (cos(t*TWO_PI*rx*tx)*0.495*t+0.5)*w;
      y= (sin(t*TWO_PI*ry*ty)*0.495*t+0.5)*h;
    } else {
      let c= map(sin(t*TWO_PI), -1, 1, 0, 255);
      stroke(c, 0, 0, c);
      let xx= (sin(t*TWO_PI*rx*tx)*0.495*t+0.5)*w;
      let yy= (cos(t*TWO_PI*ry*ty)*0.495*t+0.5)*h;
      let xxx= (cos(t*TWO_PI*rx*tx)*0.495*t+0.5)*w;
      let yyy= (sin(t*TWO_PI*ry*ty)*0.495*t+0.5)*h;
      line(x, y, xx, yy);
      line(xx, yy, xxx, yyy);
      x= xxx;
      y= yyy;
    }
  }
  index++;
}
Ndef(\sway).play
(
Ndef(\sway, {var n= 23; LeakDC.ar(Splay.ar({|i|
  var t= i/n;
  var f= t.linexp(0, 1, LFTri.ar(0.04, t*4, 400, 600), LFTri.ar(0.03, t*4, 400, 600));
  var a= SinOsc.ar(SinOsc.ar(0.02, t*pi, 0.5), 0, 0.5).max(0);
  SinOsc.ar(f+SinOsc.ar(f, 0, f*a), LFTri.ar(SinOsc.ar(t+0.01, t, 20), t*4, 4pi), a)
}!n))});
)
Ndef(\sway).stop