fractalkitty looking for math? fractalkitty.com

early works

3xrect

#random#animation#math

var x = 0;
function setup() {
  createCanvas(400, 400);
  frameRate(1);
}
function draw() {
  num =  pow(3,x);
  background(0)//set a black background
  fill(255);//fill boxes with white
  for(let i = 1; i < num; i++){//for loop to draw 3^x boxes
    rect(random(395),random(395),5,5)//draw rectangle in random location
  }
  fill(255)//make a white rectangle diameter text
  rect(330,0,100,20)//rectangle for diameter text
  fill(0)//make the text black
  text(str(num),350,12)//diamter text box
  x = x+1;//increase the exponent by 1
  if(x == 12){//make sure that the animation loops and doesn't crash
    x = 0;//reset x
    background(255)//reset background
  } 
}