fractalkitty looking for math? fractalkitty.com

codepen challenges

toggled existence

#random#trig#vectors#interactive#animation#poem#symmetry#sea#animals#codepen-challenge

aCenterOfBeingstrandsOfThoughtmemoriestimeOfMemorytimeOfThoughttimeOfCurrentgouramimotionOfMemorymotionOfThoughtmotionOfUniversetogglesOfTimetheExistenceOfMemoryoriginOfMemorytheExistenceOfThoughtoriginOfThoughtflowOfTime


let aCenterOfBeing;
let strandsOfThought = [];
let memories = [];
let timeOfMemory = 0;
let timeOfThought = 0;
let timeOfCurrent = 0;
let gourami = 100;
let motionOfMemory = true;
let motionOfThought = true;
let motionOfUniverse = true;
function setup() {
  createCanvas(720, 720);
  aCenterOfBeing = width / 2;
  originOfThought();
  originOfMemory();
}
function draw() {
  translate(width / 2, height / 2);
  background(20);
  flowOfTime();
  theExistenceOfThought();
  theExistenceOfMemory();
  togglesOfTime();
}

function togglesOfTime() {
  if (motionOfThought) {
    fill(100, 100, 100, 150);
    timeOfThought = 20 * PI * sin(frameCount / 1000);
  } else {
    fill(30, 30, 30, 150);
    frameCount--;
  }

  circle(-30, height / 2 - 20, 30);

  if (motionOfUniverse) {
    fill(150, 100, 150, 150);
    timeOfCurrent += 0.01;
  } else {
    fill(60, 30, 60, 150);
  }

  circle(0, height / 2 - 20, 30);

  if (motionOfMemory) {
    fill(100, 90, 150, 150);
    timeOfMemory += 0.01;
  } else {
    fill(20, 20, 60, 150);
  }

  circle(30, height / 2 - 20, 30);
}
function theExistenceOfMemory() {
  for (let i = 0; i < memories.length; i++) {
    for (let j = 0; j <= int(memories[i].z + 1); j++) {
      stroke(
        100 + 50 * sin(memories[i].x / 100 + j / 100),
        100 + 50 * sin(memories[i].y / 100 + j / 100),
        100 + (100 * sin(memories[i].z + j / 100)) / 100,
        40
      );
      deltaB = circle(
        memories[i].x + 20 * sin((timeOfMemory * memories[i].z) / 20),
        memories[i].y +
          height * sin((timeOfMemory * memories[i].z) / 200 + memories[i].z),
        memories[i].z - j
      );
    }
  }
}
function originOfMemory() {
  for (let i = 0; i < gourami; i++) {
    memories[i] = createVector(
      random(-aCenterOfBeing, aCenterOfBeing),
      random(-height / 2, height / 2),
      random(4, 20)
    );
  }
}
function theExistenceOfThought() {
  noFill();

  for (let i = 0; i < strandsOfThought.length; i++) {
    beginShape();
    for (let j = 0; j < strandsOfThought[i].length; j++) {
      stroke(
        0 + 100 * abs(sin((timeOfThought + i) / 50 + j - i)),
        20 + 80 * abs(sin(timeOfThought / 50 + j - i)),
        40 + 120 * abs(sin((timeOfThought + j + i) / 50 + j - i)),
        200
      );
      strokeWeight(5 * abs(sin(i * 2 + j * 2 - timeOfThought / 100)));
      vertex(
        strandsOfThought[i][j].x +
          ((height / 2 - j) / 5) *
            sin(
              j / 200 +
                timeOfThought / 10 +
                j / 50 +
                (sqrt(i + j) * timeOfThought) / 50 +
                (i * j) / 1000
            ),
        strandsOfThought[i][j].y
      );
    }
    endShape();
  }
}
function originOfThought() {
  for (let i = 0; i <= aCenterOfBeing / 4; i += 2) {
    strandsOfThought[i / 2] = [];
    delta = random(-2, 2);
    for (let j = 0; j <= height; j += 2) {
      delta = delta + 1 * sin(j / 1000 + i);
      x = -aCenterOfBeing / 2 + i * 4 + delta;
      y = -height / 2 + j;
      strandsOfThought[i / 2][j / 2] = createVector(x, y);
    }
  }
}
function flowOfTime() {
  push();
  strokeWeight(4);
  for (let i = -height / 2; i <= height; i += 1) {
    stroke(215 - i, 215 - i / 1.5, 220 - i / 4, 60);
    line(
      -aCenterOfBeing / 2 +
        (aCenterOfBeing / 4) * sin(timeOfCurrent / 3 + i / 50),
      -height / 2 + 1.2 * i,
      aCenterOfBeing / 2 +
        (aCenterOfBeing / 4) * sin(timeOfCurrent / 7 + i / 50),
      -height / 2 + i
    );
  }
  for (let i = -height / 2; i <= height; i += 1) {
    stroke(255 - i / 4, 205 - i / 1.5, 200 - i / 4, 30);
    line(
      -aCenterOfBeing / 2 +
        (aCenterOfBeing / 4) * sin(timeOfCurrent / 5 - i / 70),
      height / 2 - 1.2 * i,
      aCenterOfBeing / 2 +
        (aCenterOfBeing / 4) * sin(timeOfCurrent / 6 - i / 70),
      height / 2 - i
    );
  }
  pop();
}
function mousePressed() {
  if (dist(mouseX, mouseY, width / 2 - 30, height - 20) < 15) {
    motionOfThought = !motionOfThought;
  }
  if (dist(mouseX, mouseY, width / 2, height - 20) < 15) {
    motionOfUniverse = !motionOfUniverse;
  }
  if (dist(mouseX, mouseY, width / 2 + 30, height - 20) < 15) {
    motionOfMemory = !motionOfMemory;
  }
}