fractalkitty looking for math? fractalkitty.com

Genuary 2026

Genuary Day 9 + Day 10

#random#trig#classes#interactive#animation#study#cellular-automata#genuary

beingsdepthstepAholeRdeltaDBeing


let beings;
let n;
let depth;
let stepA;
let holeR;
let cnt;
let t = 0;

function setup() {
  cnv = createCanvas(600, 600);
  background(255);
  beings = [];
  n = int(random(24, 180));
  depth = int(random(80, 200));
  holeR = random(5, width / 4);
  let deltaD = (width - holeR - 20) / depth;
  stepA = (2 * PI) / n;
  cnt = 0;
  for (let i = 0; i < n; i++) {
    for (let j = 0; j < depth; j++) {
      beings.push(new Being(cnt, holeR + j * deltaD, (i % n) * stepA));
      cnt++;
    }
  }
  describe(
    "circle of small arc strokes playing out a game of life with small strands of same teal color palette appearing as gossamer"
  );
  strokeWeight(2);
  noFill();
  frameRate(3);
}

function draw() {
  t += 0.001;
  translate(width / 2, height / 2);
  background(255, 255, 255, 100);
  rotate(t);
  for (let i = 0; i < beings.length; i++) {
    beings[i].assessThyself();
    beings[i].display();
  }
}

class Being {
  constructor(id, r, theta) {
    this.id = id;
    this.r = r;

    this.awakeCount = 0;
    this.offset = random(-0.2, 0.2);
    this.theta = theta + this.offset;
    this.c = [random(100, 150), random(180, 240), random(200, 255), 150];
    this.awake = random([true, false]);
    this.randomNeighbor = int(random());
    this.neighbors = [];
    this.nN = int(random(1, 7));
    for (let i = 0; i < this.nN; i++) {
      this.neighbors.push(int(random(0, cnt - 1)));
    }
  }
  display() {
    if (this.awake) {
      stroke(this.c);
    } else {
      stroke(255, 255, 255, 50);
    }

    arc(0, 0, this.r, this.r, this.theta, this.theta + stepA / 1.3);
    for (let i = 0; i < this.neighbors.length; i++) {
      push();
      stroke(this.c);
      strokeWeight(0.05);
      if (beings[this.neighbors[i]].awake && this.awake) {
        line(
          (this.r / 2) * cos(this.theta),
          (this.r / 2) * sin(this.theta),
          (beings[this.neighbors[i]].r / 2) *
            cos(beings[this.neighbors[i]].theta),
          (beings[this.neighbors[i]].r / 2) *
            sin(beings[this.neighbors[i]].theta)
        );
      }
      pop();
    }
  }
  assessThyself() {
    this.awakeCount = 0;

    for (let i = 0; i < this.neighbors.length; i++) {
      if (beings[this.neighbors[i]].awake) {
        this.awakeCount++;
      }
    }

    if (this.awakeCount > 3) {
      this.awake = !this.awake;
    }

    if (this.awakeCount === 2 && this.awake) {
      this.awake = false;
    }

    if (this.awakeCount === 0 && !this.awake) {
      this.awake = true;
    }
  }
}

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