fractalkitty looking for math? fractalkitty.com

weekly creative coding

arcs are we

#random#trig#animation#poem#wcc

arcsnArcsdiamgenerateArc

let arcs, t;
let nArcs = 400,
  diam = 100,
  a = 0.005;
function setup() {
  arcs = [];
  createCanvas(windowWidth, windowHeight * 0.8);
  angleMode(DEGREES);
  for (let i = 0; i < nArcs; i++) {
    p = random(0, diam);
    arcs[i] = {
      z1: -p,
      z2: p,
      rotation: random(0, 360),
      color: [random(240, 255), random(180, 234), random(150, 200), 250]
    };
  }
  background(10, 40, 60);
}
function draw() {
  t = frameCount / 4;
  background(10, 40, 60, 2 + 50 * abs(sin(t)));
  diam = (width / 4) * sin(t / 5);
  translate(width / 2, height / 2);
  push();
  generateArc();
  pop();
}

function generateArc() {
  noStroke();
  for (let i = 0; i < arcs.length; i++) {
    push();
    fill(arcs[i].color);
    rotate(arcs[i].rotation);
    t1 =
      a *
      arcs[i].z2 *
      sin(t + 0.01 * arcs[i].rotation * sin(t + random(0, 10)));

    x = random(-0.5, 0.5) + t1 / a + arcs[i].z1 + arcs[i].z2;
    y = a * (t1 / a + arcs[i].z2) * (t1 / a + arcs[i].z1);
    d = dist(x, y, 0, 0);
    circle(x + diam, y, 2 * cos(t / 4 + d + arcs[i].z1));
    pop();
  }
}