fractalkitty looking for math? fractalkitty.com

all

perpetual painting

#random#image#interactive#animation#accumulates

strokeMaxvarRotvarwinput1button1paintbuttonsloadF

let strokeMax, varRot, varw;
let input1, button1;
let cnt = 200;
let img;
function preload() {
  img = loadImage(
    "/assets/F9506DF4-C5FD-4B1F-B3A7-FDD76B76A460.jpeg"
  );
}
function setup() {
  c = min(windowWidth, windowHeight);
  cnv = createCanvas(
    (c * img.width) / img.height,
    (c * img.height) / img.width
  );
  background(0);
  buttons();
  noStroke();
  strokeMax = random(0.5, 40);
  varRot = random(0, PI);
  varW = random(0.5, 10);
}
function draw() {
  for (let i = 0; i < cnt; i++) {
    w = random(0.5, strokeMax);
    paint();
  }
}

function paint() {
  x = random(-40, width + 40);
  y = random(-40, height + 40);
  pix = img.get(img.width / (width / x), img.height / (height / y));
  fill(pix);
  push();

  translate(x, y);
  rotate(varRot + random(0, PI / 9));
  for (let h = 0; h < 10; h++) {
    fill(
      pix[0] + random(-20, 20),
      pix[1] + random(-20, 20),
      pix[2] + random(-50, 50),
      50
    );
    rect(0, 0, random(w - varW, w + varW), 8 - h, 2, 2);
  }
  pop();
}

function windowResized() {
  c = min(windowWidth, windowHeight);
  cnv = resizeCanvas(
    (c * img.width) / img.height,
    (c * img.height) / img.width
  );
  noStroke();
  strokeMax = random(0.5, 40);
  varRot = random(0, PI);
  varW = random(0.5, 10);
  draw();
}

function buttons() {
  input1 = createInput();
  input1.position(20, windowHeight - 50);
  input1.size(width / 3, 15);
  button1 = createButton("load URL");
  button1.position(width / 3 + 40, windowHeight - 50);
  button1.mousePressed(loadF);
}

function loadF() {
  img = loadImage(input1.value());
  windowResized();
}

function keyPressed() {
  if (keyCode === 73) {
    setup();
    draw();
  }
}