fractalkitty looking for math? fractalkitty.com

Genuary 2024

vera style

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

vShapeborder


function setup() {
  createCanvas(windowWidth * 0.9, windowHeight * 0.9);
  n = int(random(20, 40));
  m = int(random(5, 10));
  fill(255);
  stroke(255);
  angleMode(DEGREES);
}

function draw() {
  background(10, 30, 40);
  translate(width / 2, height / 2);
  t = 360 * sin(frameCount / 10);
  for (let j = 1; j < m; j++) {
    for (let i = 0; i < n + j * 2; i++) {
      push();

      rotate((360 / (n + j * 2)) * i);
      translate((j * width) / 12, 0);
      scale((1.4 * j) / m);
      rotate(t + j * 180);
      vShape();
      pop();
    }
  }

  border();
}
function vShape() {
  fill(255, 255, 255);
  d = width / 40;
  rect(-d, -d, d, 2 * d);
  triangle(-d, -d, -d, -1.5 * d, -d / 2, -d);
  triangle(0, -d, 0, -1.5 * d, -d / 2, -d);
}

function border() {
  push();
  rectMode(CENTER);
  noFill();
  stroke(20, 50, 60);
  strokeWeight(4);
  rect(0, 0, width - 20, height - 20);
  pop();
}

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

function windowResized() {
  resizeCanvas(windowWidth * 0.9, windowHeight * 0.9);
}