fractalkitty looking for math? fractalkitty.com

100 days of code

gearDance

#trig#animation#math

makeGeargearSetfullSheet

function setup(){
  createCanvas(windowWidth,windowHeight);
  noStroke()
}
function draw(){
  background(255);
  t=frameCount/90
  translate(width/2,height/2);
  scale(1.5+0.2*sin(t/2),1.5+0.2*sin(t/2))
  push()
  fill(0,30,50,180)
  rotate(TWO_PI*sin(t/100))
  fullSheet()
  pop()
  fill(0,0,0,220);
  fullSheet();
}

function makeGear(teeth,diameter,x,y,t){
  push()
  translate(x,y);
  rotate(t);
  circle(0,0,diameter);
  c=PI*diameter;
  w=(c/teeth)/2;
  push()
    for(let i=0;i<teeth;i++){
      rotate(TWO_PI/teeth)
      rect(-w/2,diameter/2-w/2,w,w);
    }
  pop()
  pop()
  
}
function gearSet(){
  makeGear(10,100,0,0,t)
  makeGear(20,200,162,0,-t/2)
  makeGear(20,200,-162,0,-t/2)
  makeGear(10,100,325,0,t)
  makeGear(10,100,-325,0,t)
  makeGear(20,200,-487,0,-t/2)
  makeGear(20,200,487,0,-t/2)
  makeGear(10,100,-162,162,t-0.32)
  makeGear(10,100,162,162,t-0.32)
  makeGear(20,200,0,162,-t/2+0.47)
  makeGear(20,200,325,162,-t/2+0.47)
  makeGear(20,200,-325,162,-t/2+0.47)
  makeGear(10,100,-487,162,t-0.32)
  makeGear(10,100,487,162,t-0.32)
}

function fullSheet(){
  gearSet();
  push()
  translate(0,325);
  gearSet()
  pop()
  push()
  translate(0,-325);
  gearSet()
  pop()
}