fractalkitty looking for math? fractalkitty.com

early works

constellationWeb

#random#interactive#animation#accumulates#math#sky

pArrayinclimitnMarkerdMarkerpointArraycreateButtonsresketch

let pArray = [];
let n
let d = 2;
let inc = 0.5;
let limit
let nMarker = 2;
let dMarker = 0;
function setup() {
  createCanvas(windowWidth, windowHeight);
  translate(width / 2, height / 2);
  background(0);
  n = nMarker * 300 + 300;
  limit = dMarker * 10 + 20;
  pointArray();
  fill(255);
  stroke(255);

}

function draw() {
  translate(width / 2, height / 2);
  createButtons();
  if (d < limit) {
    for (let i = 0; i < n; i++) {
      for (let j = 0; j < n; j++) {
        distance = dist(pArray[i][0], pArray[i][1], pArray[j][0], pArray[j][1]);
        if (i != j && distance <= d && distance > d - inc) {
          line(pArray[i][0], pArray[i][1], pArray[j][0], pArray[j][1]);
        }
      }
    }
    d += inc;
  }
}

function pointArray() {
  fill(255);
  noStroke();
  for (let i = 0; i < n; i++) {
    a = random(-width / 2, width / 2);
    b = random(-width / 2, width / 2);
    pArray[i] = [a, b];
    circle(pArray[i][0], pArray[i][1], 1);
  }
}

function mousePressed() {}

function createButtons() {
  strokeWeight(1);
  for (let i = 0; i < 10; i++) {
    if (nMarker === i) {
      fill(255, 255, 255, 100);
    } else {
      fill(0);
    }
    circle(-width / 2 + 50 + i * 15, -height / 2 + 10, 10);
    if (dMarker === i) {
      fill(255, 255, 255, 100);
    } else {
      fill(0);
    }
    circle(-width / 2 + 20, -height / 2 + 50 + i * 15, 10);
  }
  strokeWeight(0.05);
}

function keyPressed() {
  if (keyCode === 39) {
    if (nMarker < 9) {
      nMarker++;
      n = nMarker * 300 + 300;
      resketch();
    } else {
      nMarker = 0;
      n = nMarker * 300 + 300;
      resketch();
    }
  } else if (keyCode === 37) {
    if (nMarker > 0) {
      nMarker--;
      n = nMarker * 300 + 300;
      resketch();
    } else {
      nMarker = 9;
      n = nMarker * 300 + 300;
      resketch();
    }
  } else if (keyCode === 40) {
    if (dMarker < 9) {
      dMarker++;
    } else {
      dMarker = 0;
    }
  } else if (keyCode === 38) {
    if (dMarker > 0) {
      dMarker--;
    } else {
      dMarker = 9;
    }
  } else if (keyCode === 32) {
    resketch();
  }
  limit = dMarker * 20 + 20;
}
function resketch() {
  d = 2;
  pArray = [];
  background(0);
  pointArray();
  stroke(255);
}