fractalkitty looking for math? fractalkitty.com

Mathober 2025

Recursion

#random#trig#classes#grid#interactive#animation#math#mathober

recursesesthetaRecursesdrawGrid


let t = 0;
let n = 25;
let recurseses = [];

function setup() {
  createCanvas(500, 500);
  background(255);
  describe(
    " Dark mode of radial graph paper with lines of dark and light shooting from different angles and sometimes as arcs with starry static. The initial arcs break branch every so often and so do other ones at random times with a capacity of 800 entities. "
  );
  rectMode(CENTER);
  strokeWeight(0.5);
  strokeCap(SQUARE);
  rs = [];
  l = 100;
  k = 1;
  d = width / 25;
  r = d * k;
  recurseses = [];
  for (let i = 0; i < n * 2; i++) {
    let theta = (i * PI) / 25;
    recurseses.push(
      new Recurses(r, theta, random(-0.002, 0.002), random(0.1, 0.5), k + 1)
    );
  }
}

function draw() {
  background(30, 40, 50, 10);
  translate(width / 2, height / 2);
  stroke(100, 110, 120, 10);
  drawGrid();
  t += 0.008;
  noStroke();
  for (let i = 0; i < recurseses.length; i++) {
    recurseses[i].display();
    recurseses[i].move();
    if (abs(recurseses[i].r) > d * 9) {
      tmp = random(0, 1);
      if (tmp > 0.01) {
        recurseses.splice(i, 1);
      } else if (tmp < 0.01) {
        recurseses[i].r = r;
        recurseses[i].k = 4;
      }
    }
  }

  strokeWeight(1);
  noFill();
  stroke(100, 110, 120, 30);
  rect(0, 0, width / 1.02, width / 1.02);
  rect(0, 0, width / 1.04, width / 1.04);
}

class Recurses {
  constructor(r, theta, dS, dC, kd) {
    this.r = r;
    this.theta = theta;
    this.dS = dS;
    this.dC = dC;
    this.bloom = false;
    this.k = kd;
    this.s = 2;
  }
  display() {
    fill(
      50 + 60 * cos(t * this.dC),
      60 + 60 * cos(t * this.dC),
      70 + 60 * cos(t * this.dC)
    );

    circle(this.r * cos(this.theta), this.r * sin(this.theta), this.s);
  }
  move() {
    this.theta += this.dS / 100;
    this.r += this.dC;
    if (this.r > d * this.k && recurseses.length < 800) {
      this.k += 2;
      recurseses.push(
        new Recurses(
          this.r,
          this.theta,
          random(-0.3, 0.3),
          random(-0.5, 0.5),
          this.k
        )
      );
      recurseses.push(
        new Recurses(
          this.r,
          this.theta,
          random(-0.3, 0.3),
          random(-0.5, 0.5),
          this.k
        )
      );
    }
  }
}

function drawGrid() {
  for (let i = 0; i < n; i++) {
    rotate((2 * PI) / n);
    line(-width / 1.5, 0, width / 1.5, 0);
    circle(0, 0, (width / n) * 2 * i);
  }
  noStroke();
  for (let i = 0; i < 100; i++) {
    x = random(-width / 2, width / 2);
    y = random(-width / 2, width / 2);
    fill(245, 250, 255, 50);
    circle(x, y, 2);
  }
}

function mousePressed() {
  setup();
  draw();
}