fractalkitty looking for math? fractalkitty.com

Genuary 2024

gazing up

#random#trig#interactive#animation#geometry#genuary

designborderwavesToCenter

let design = [];
function setup() {
  c = min(700, min(windowWidth, windowHeight) * 0.9);
  cnv = createCanvas(c, c);

  design = [];
  rectMode(CENTER);
  noFill();
  angleMode(DEGREES);
  r1 = random(50, 200);
  g1 = random(50, 200);
  b1 = random(50, 200);
  nc = 400;
  for (let i = 0; i < nc; i++) {
    design[i] = {
      x: random(-width / 2, width / 2),
      y: random(-height / 2, height / 2),
      size: random(2, 5),
      color: color(
        random(r1, r1 + 80),
        random(g1, g1 + 80),
        random(b1, b1 + 80),
        250
      )
    };
  }
  noStroke();
}

function draw() {
  background(r1 + 100, g1 + 100, b1 + 100);
  translate(width / 2, height / 2);
  t = frameCount * 2;

  for (let j = 0; j < nc; j++) {
    for (let i = 0; i < 72; i++) {
      push();
      rotate(5 * i);
      push();
      fill(design[j].color);
      translate(100 * cos(j + t / 10), 100 * sin(j + t / 10));
      circle(design[j].x, design[j].y, design[j].size);
      pop();
      pop();
    }
  }
  wavesToCenter();

  border();
}

function border() {
  push();
  noFill();
  stroke(r1, g1, b1);
  strokeWeight(4);
  rect(0, 0, width - 20, height - 20);
  pop();
}

function wavesToCenter() {
  strokeWeight(2);

  for (let j = 0; j < 72; j++) {
    push();
    rotate(j * 5);
    beginShape();
    for (let i = 1; i < width / 1.5; i += 1) {
      x = i;
      y = 0;
      if (j % 2 === 0) {
        y = (i / 25) * cos(i * 8 + 360 / i + t);
      } else {
        y = (-i / 25) * cos(i * 8 + 360 / i + t);
      }
      fill(212 + 50 * cos(x), 186 + 50 * cos(x), 112);
      circle(x, y, constrain(i / 25, 1, 4));
    }
    endShape();
    pop();
  }
}

function mousePressed() {
  frameCount = 0;
  setup();
  draw();
}

function keyPressed() {
  save(cnv, "up", "jpg");
}

function windowResized() {
  c = min(700, min(windowWidth, windowHeight) * 0.9);
  resizeCanvas(c, c);
}