fractalkitty looking for math? fractalkitty.com

weekly creative coding

Salem Oregon

#random#trig#interactive#animation#accumulates#data#wcc

playBoollocTable

let w, c, r, d;
let playBool = true;
let locTable;
function preload() {
  locTable = loadTable(
    "/assets/Primary_Address.csv",
    "csv",
    "header"
  );
}

function setup() {
  w = min(windowWidth, windowHeight) * 0.9;
  randomWalk = [];
  cnv = createCanvas(w, w);
  dataX = locTable.getColumn("X");
  dataY = locTable.getColumn("Y");
  minX = min(dataX);
  maxX = max(dataX);
  minY = min(dataY);
  maxY = max(dataY);
  background(0);
  noStroke();
  x1 = [];
  y1 = [];
  n = 2 + random([0, 1, 2, 3, 4, 5, 6, 7]);
  c = random(1, 10);
  d = random(1, 10);
  f = int(random(5, 12));
  for (let i = 0; i < dataX.length; i++) {
    x1[i] = map(dataX[i], minX, maxX, -w / 2.5, w / 2.5);
    y1[i] = map(dataY[i], minY, maxY, -w / 2.5, w / 2.5);
    fill(255);
    circle(w / 2 + x1[i], w / 2 + y1[i], 1);
  }
}
function draw() {
  translate(w / 2, w / 2);
  if (playBool) {
    t = frameCount / 200;
    n = random([2, 3, 4, 5, 6, 7]);
    for (let i = 0; i < dataX.length; i += n) {
      x = x1[i];
      y = y1[i];
      fill(255 * abs(cos((t * f) / 7)));
      circle(x, y, 1);
      fill(255 * abs(sin((t * f) / 7)));
      circle(
        x * cos(t / d) +
          (w / 7) * cos(t * sin(i % f) * c) * sin(t) * cos(i / d),
        y * cos(t / d / 2) +
          (w / 9) * cos((t * sin(i % (f * 2)) * c) / 2) * sin(t) * cos(i / c),
        0.5
      );
    }
  }
}

function keyPressed() {
  if (keyCode === 32) {
    playBool = !playBool;
  }
  if (keyCode === 83) {
    save(cnv, "salem", ".png");
  }
}