‹ pakt22 pakt24 ›

pakt23


pact23sway, 01:00, 1.84MB

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

//pakt23
let index
let n
function setup() {
  const div = select('#sketch')
  const cnv = createCanvas(div.width, div.height)
  cnv.parent('sketch')
  frameRate(60)
  noStroke()
  background(175)
  index = 0
  n = 250
}
function draw() {
  const rx = sin(index * 0.0024)
  const ry = sin(index * 0.0022 + 1)
  const tx = sin(index * 0.0016 + 2) + rx
  const ty = sin(index * 0.0018 + 3) + ry

  noStroke()
  fill(color(255, 255, 255, 5))
  rect(0, 0, width, height)

  let x = 0.5 * width
  let y = 0.5 * height
  for (let i = 50; i < n; i++) {
    const t = i / n
    if (i == 50) {
      x = (cos(t * TWO_PI * rx * tx) * 0.495 * t + 0.5) * width
      y = (sin(t * TWO_PI * ry * ty) * 0.495 * t + 0.5) * height
    } else {
      const c = map(sin(t * TWO_PI), -1, 1, 0, 255)
      stroke(c, 0, 0, c)
      const xx = (sin(t * TWO_PI * rx * tx) * 0.495 * t + 0.5) * width
      const yy = (cos(t * TWO_PI * ry * ty) * 0.495 * t + 0.5) * height
      const xxx = (cos(t * TWO_PI * rx * tx) * 0.495 * t + 0.5) * width
      const yyy = (sin(t * TWO_PI * ry * ty) * 0.495 * t + 0.5) * height
      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