fractalkitty looking for math? fractalkitty.com

Genuary 2022

incohesive square

#random#trig#classes#interactive#animation#math#genuary

partsparty

let t = 0;
let d = false;
let parts = [];
let n = 5000;
function setup() {
  createCanvas(windowWidth, windowHeight);
  background(random(0, 50));
  rectMode(CENTER);
  angleMode(DEGREES);
  noStroke();
  n = 5000;
  for (let i = 0; i < n; i++) {
    parts.push(new party());
  }
}

function draw() {
  translate(width / 2, height / 2);

  background(0);
  if (d) {
    t += 0.5;
    rotate(t);
  } else {
    t = 0;
  }
  for (let i = 0; i < n; i++) {
    parts[i].move();
    parts[i].display();
  }
}

function mousePressed() {
  d = !d;
}
class party {
  constructor() {
    this.x1 = random(-50, 50);
    this.y1 = random(-50, 50);
    this.speed = random(2, 5);
    this.x = this.x1;
    this.y = this.y1;
  }
  move() {
    this.x =
      this.x1 * cos(t) * cos(t) * tan(t / 2 - 45) +
      (width / 6) * this.speed * sin(t / 2) * cos(t / 3);
    this.y =
      this.y1 * cos(t) -
      (height / 5) * tan(t) -
      this.y1 * sin(t) * tan(t / 5 - this.y1);
  }
  display() {
    circle(this.x, this.y, 4);
  }
}