fractalkitty looking for math? fractalkitty.com

Genuary 2024

32x32 binary

#random#trig#interactive#animation#genuary

border


function setup() {
  c = min(320, 320);
  createCanvas(c, c);
  angleMode(DEGREES);
  d = width / 32;
  p1 = int(random(3, 10));
  p2 = int(random(3, 10));
  p3 = int(random(3, 10));
  p4 = int(random(-5, 5));
  p5 = int(random(-5, 5));
  p6 = int(random(-5, 5));
  r = int(random(100, 255));
  g = int(random(100, 255));
  b = int(random(100, 255));
  background(r, g, b);
}

function draw() {
  background(10, 30, 40);

  translate(width / 2, height / 2);
  t = frameCount;
  noStroke();
  for (let i = 0; i < 32; i++) {
    for (let j = 0; j < 32; j++) {
      x = -c / 2 + d * i;
      y = -c / 2 + d * j;
      dst = min(
        dist(
          x,
          y,
          (width / 4) * cos(t) - (width / 5) * sin(t / 2) * cos(t),
          (width / 4) * sin(t) - (width / 5) * sin(t / 3) * cos(t / 2)
        ),
        dist(
          x,
          y,
          (-width / 4) * cos(t) - (width / 5) * sin(t / 2) * cos(t),
          (-width / 4) * sin(t) - (width / 5) * sin(t / 3) * cos(t / 2)
        )
      );
      fill(
        r - dst / p4 - (dst / p1) * sin(x * y - (t * x) / b),
        g - dst / p5 - (dst / p2) * sin(x * y - (t * x) / r),
        b - dst / p6 - (dst / p3) * sin(x * y - (t * x) / g)
      );
      rect(x, y, d, 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();
}