fractalkitty looking for math? fractalkitty.com

all

NoC - pairing RC D1 Randomness

#random#classes#color#animation#random-walk#recurse-center

colorsfunWalkersnWalkersbgcrandDistcolorPaletteWalker

const colors = [
  "#32272e",
  "#40415e",
  "#4166a6",
  "#178df6",
  "#8a8eff",
  "#cd85fe",
  "#f97ef9",
  "#c0a4c9",
  "#78bd99",
  "#3fc580",
  "#060305",
  "#263437",
  "#528087",
  "#80d5e1",
  "#9be8e6",
  "#aff2df",
  "#c3fbda",
  "#d9f6e0",
  "#eef1e7",
  "#f8ecea"
];

let funWalkers = [];
let nWalkers = 400;
let bgc;
let randDist = 2;
function setup() {
  console.log("hi");
  createCanvas(windowWidth, windowHeight);
  bgc = color(random(colors));
  bgc.setAlpha(2);

  for (let i = 0; i < nWalkers; i++) {
    funWalkers.push(new Walker());
  }
}

function draw() {
  background(bgc);
  for (let i = 0; i < funWalkers.length; i++) {
    funWalkers[i].display();
    funWalkers[i].move();
  }
}

function colorPalette() {
  for (i = 0; i < colors.length; i++) {
    fill(colors[i]);
    circle(50 + i * 20, 20, 20);
    fill(0);
    noStroke();
    text(str(i), 50 + i * 20, 40);
  }
}

class Walker {
  constructor() {
    this.x = random(0, width);
    this.y = random(0, height);
    this.color = random(colors);
    this.eyeColor = random(colors);
    this.d = randomGaussian(15, 6);
  }
  display() {
    noStroke();
    fill(this.color);
    circle(this.x, this.y, this.d);

    fill(this.eyeColor);
    circle(this.x + this.d / 5, this.y, this.d / 5);
    fill(this.eyeColor);
    circle(this.x - this.d / 5, this.y, this.d / 5);
  }

  move() {
    this.x = this.x + random(-randDist, randDist);
    this.y = this.y + random(-randDist, randDist);
  }
}

function windowResized() {
  resizeCanvas(windowWidth, windowHeight);
}