fractalkitty looking for math? fractalkitty.com

100 days of code

focus

#random#trig#interactive#animation#math#symmetry#polar

playB


let r,a=3,b=2,c=4
let playB = true;
function setup() {
  cnv = createCanvas(720, 720);
  noFill()
  angleMode(DEGREES)
  strokeWeight(0.05)
  r=80;
}

function draw() {
  translate(width/2,width/2);
  if (playB){
  t=frameCount/2
  x1=r*sin(t*c)
  y1=r*cos(t*c)
  x2=r*2*sin(t*a);
  y2=r*2*cos(t*a)
  x3=r*3*sin(t*b);
  y3= -r*3*cos(t*b)
  triangle(x1,y1,x2,y2,x3,y3)
  if(t>360){
    frameCount=0;
    background(255,255,255,30)
    a=int(random(-12,12));
    b=int(random(-10,10));
    c=int(random(1,4));
    r=int(random(40,150))
  }
  }else{frameCount--}
}

function mousePressed(){
  background(255)
  frameCount=0;
  a=int(random(-12,12));
  b=int(random(-10,10));
  c=int(random(1,4));
  
}

function keyPressed(){
  playB=!playB 
  if(keyCode===83){
    save(cnv,"focus",'png')
  }
}