fractalkitty looking for math? fractalkitty.com

100 days of code

pareidolia

#random#trig#animation#accumulates#random-walk

oldxoldy

let k,a=200;
let oldx=0;
let oldy=0;
function setup(){
  cnv=createCanvas(windowWidth,windowHeight);
  k=random(-20,20);
  print(k);
  fill(0);
  angleMode(DEGREES);
  background(240)
}
function draw(){
  translate(width/2,height/2);
  stroke(0);
  t=frameCount;
  p=random(-1,1);
  if (p>0){
    p=5;
  }
  if (p<0){
    p=-5;
  }
  q=random(-1,1);
  if (q>0){
    q=5;
  }
  if (q<0){
    q=-5;
  }
  x=oldx+p*cos(p+oldx*t)*cos(t+oldy);
  y=oldy+q*cos(q+oldy*t)*sin(t+oldx);
  if (x>width/2){
    oldx=oldx-width;
    x=x-width
  }
  if (x<-width/2){
    oldx=oldx+width;
    x=x+width
  }
  if (y>width/2){
    oldy=oldy-width;
    y=y-width
  }
  if (y<-width/2){
    oldy=oldy+width;
    y=y+width
  }
  line(oldy,oldx,y,x);
  oldx=x;
  oldy=y;
}