‹ pakt20pakt22 ›

pakt21


pact21flush, 01:00, 1.84MB

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

//pakt21
let index, n
let last = []
let cols = []
function setup() {
  const div = select('#sketch')
  const cnv = createCanvas(div.width, div.height)
  cnv.parent('sketch')
  frameRate(60)
  noStroke()
  n = 150
  index = 0
  last = []
  cols = []
  for (let i = 0; i < n; i++) {
    const t = (i / n) * TWO_PI
    last[i] = []
    last[i][0] = 0
    last[i][1] = 0
    cols[i] = color(sin(t) * 127.5 + 127.5, sin(t + PI) * 127.5 + 127.5, 255)
  }
  background(0)
}
function draw() {
  fill(color(0, 0, 0, 13))
  rect(0, 0, width, height)
  for (let i = 0; i < n; i++) {
    const x = sin((i * (sin(index * 0.0126 + sin(i) * sin(i * 2)) * sin(index * 0.0031)) + index) * 0.074)
    const y = cos((i * (sin(index * 0.0152 + sin(i) * sin(i * 2)) * sin(index * 0.0021)) + index) * 0.064)
    const pos = [x * width * 0.45 + width * 0.5, y * height * 0.45 + height * 0.5]
    if (index > 0) {
      fill(cols[i])
      const r = abs(pos[0] - last[i][0] + (pos[1] - last[i][1])) * 0.5
      ellipse(pos[0], pos[1], r * 2, r * 2)
    }
    last[i][0] = pos[0]
    last[i][1] = pos[1]
  }
  index++
}

Ndef(\flush).play
(
Ndef(\flush, {var a= {|i| 2.pow(i)}!7; Mix(
  Pan2.ar(
    Resonz.ar(SinOsc.ar(0, GrayNoise.ar(a*30*pi), 0.5), a*300, SinOsc.ar(a*0.13, 0, 0.4, 0.5)),
    SinOsc.ar(a*0.03, 0, 0.95)
  )
)});
)
Ndef(\flush).stop