fractalkitty looking for math? fractalkitty.com

Genuary 2022

3 Color Dance

#noise#random#trig#vectors#interactive#animation#math#genuary

pointspoints1

let points = [];
let points1 = [];
let n;
let t = 0;
let nf;

function setup() {
  tmp = min(windowWidth, windowHeight) * 0.99;
  createCanvas(tmp, tmp);
  n = int(tmp);
  nf = random(0.0005, 0.001);
  mf = random(2, 100);
  for (i = 0; i < n; i++) {
    c = random(width);
    theta = random(-PI, PI);
    points[i] = createVector(c * sin(theta), c * cos(theta));
    points1[i] = createVector(
      c * sin(theta) * sin(theta / 2),
      c * cos(theta) * cos(theta / 4)
    );
  }
  strokeWeight(0.1);
  background(0);
}

function draw() {
  t = frameCount / 100;
  background(0, 0, 0, 5);
  translate(width / 2, height / 2);
  noStroke();
  fill(0);
  rect(-width / 2, -height / 2, width / 10, height);
  rect(width / 2 - width / 10, -height / 2, width / 10, height);
  rect(-width / 2, -height / 2, width, width / 10);
  rect(-width / 2, height / 2 - width / 10, width, width / 10);
  push();
  rotate(PI / 4);

  stroke(255);
  for (let i = 0; i < points1.length; i++) {
    n1 =
      noise(points1[i].x * nf, points1[i].y * nf) * sin(t / 2) + 0.1 * cos(t);
    points1[i].add(cos(n1 * mf), sin(n1 * mf));

    for (let j = 1; j < 5; j++) {
      x = constrain(
        points[i].x / (2 * j),
        -width / 2 + width / 20,
        width / 2 - +width / 20
      );
      y = constrain(
        points[i].y / (2 * j),
        -width / 2 + width / 20,
        width / 2 - +width / 20
      );

      point(x, -y);
      point(-x, y);
    }
  }
  stroke(205, 255, 255);
  for (let i = 0; i < points.length; i++) {
    n1 = noise(points[i].x * nf, points[i].y * nf) * sin(t / 2) + 0.1 * cos(t);
    points[i].add(cos(n1 * mf), sin(n1 * mf));

    for (let j = 1; j < 3; j++) {
      x = constrain(
        points[i].x / (2 * j),
        -width / 2 + width / 12,
        width / 2 - +width / 12
      );
      y = constrain(
        points[i].y / (2 * j),
        -width / 2 + width / 12,
        width / 2 - +width / 12
      );
      point(x, y);
      point(-x, -y);
    }
  }
  pop();
}

function mousePressed() {
  setup();
}