fractalkitty looking for math? fractalkitty.com

Coded Poems

charcoaled vortex

#noise#random#trig#vectors#classes#interactive#poem#polar

a coded poem

theConditionsOfThisSpacecharcoalSmearstheta

let theConditionsOfThisSpace;
let charcoal = [];
function setup() {
  theConditionsOfThisSpace = {
    coincidence: random([-1, 1]) * random(0.0001, 0.009),
    chance: random(0.1, 150) * random([-1, 1])
  };
  cnv = createCanvas(550, 850);
  charcoal.push(new Smears(random(width / 6, width / 4), 0, 0));
  noStroke();
  fill(0, 0, 0, 5);
}
function draw() {
  translate(width / 2, height / 2);
  charcoal[0].move();
  if (frameCount > 300) {
    noLoop();
  }
}

class Smears {
  constructor(r, x, y) {
    this.centeredGrainAcross = x;
    this.centeredGrainUp = y;
    this.smudgiling = [];
    this.sourceOfMotion = 0;
    this.curvature = int(random(10, 60));
    this.granules = random(500, 1500);
    for (let i = 0; i < this.granules; i++) {
      let theta = random(0, TWO_PI);
      this.smudgiling[i] = createVector(
        randomGaussian(0, width / 10) + r * sin(theta),
        randomGaussian(0, width / 10) + r * cos(theta)
      );
    }
  }
  move() {
    push();
    translate(this.centeredGrainAcross, this.centeredGrainUp);
    this.sourceOfMotion += 0.1;
    for (let i = 0; i < this.smudgiling.length; i++) {
      let n =
        noise(
          theConditionsOfThisSpace.coincidence *
            this.smudgiling[i].x *
            cos(this.sourceOfMotion / 200),
          theConditionsOfThisSpace.coincidence *
            this.smudgiling[i].y *
            cos(this.sourceOfMotion / 200)
        ) * theConditionsOfThisSpace.chance;

      this.smudgiling[i].add(
        cos(n) * sin(n / 5 + random(-width * 4, width * 4)),
        sin(n) * cos(n / 5)
      );
      for (let sc = 1; sc < this.curvature; sc += 1) {
        push();
        scale(1.5 / sqrt(sc * 1.5), 1.5 / sqrt(sc * 1.5));
        rotate(((PI * 2) / this.curvature) * sc + this.sourceOfMotion / 50);
        circle(this.smudgiling[i].x, this.smudgiling[i].y, 150 / (width / 5));
        pop();
      }
    }
    pop();
  }
}

function keyPressed() {
  if (keyCode === 32) {
    charcoal = [];
    frameCount = 0;
    setup();
    loop();
    draw();
  }
  if (keyCode === 83) {
    save(cnv, "charcoaledVortex", "png");
  }
}