fractalkitty looking for math? fractalkitty.com

Mathober 2023

Mathober Day-8: Counting

#random#trig#image#interactive#animation#accumulates#poem#math#spiral#sky#time#mathober

img1img2


let img1, img2;
let d = 150;

function preload() {
  img1 = loadImage("/assets/counting.jpg");
  img2 = loadImage("/assets/star.png");
}

function setup() {
  createCanvas(600, 600);
  background(img1);
  angleMode(DEGREES)
  noStroke()
    a = random(-0.5,0.5);
  k=random(0.01,0.1);
  b = 0
  frameCount = 0
}

function draw() {
  t = frameCount ;

  translate(width/2,height/2);
  if(t %180 == 0){
    noFill()
    d = random(5,50)
  }else{
    fill(255)
    d=0.5
    
  }
  if(d<5){
    circle(a*((t+b)*cos(t+b)+k*(t+b)),a*(t+b)*sin(t+b),d)
  }else{
     image(img2,a*((t+b)*cos(t+b)+k*(t+b))-d/2,a*(t+b)*sin(t+b)-d/2,d,d)
  }
  
 
  if(a*(t*cos(t)+k*t)>width/2){
    frameCount =0
    a = random(0.01,0.5);
  k=random(0.01,0.1);
  b = random(0,180)
  }
}

function keyPressed(){
  setup()
  
  draw()
}