fractalkitty looking for math? fractalkitty.com

100 days of code

spiralDrops_Day15

#trig#animation#spiral

shapeDcenterPsideP

let a = 30,b=30,c = 60;
function setup() {
  createCanvas(500, 500);
  angleMode(DEGREES);
  strokeWeight(0.1)
  fill(0)
}

function draw() {
  background(255,255,255,2);
  translate(width/2,width/2)
  t = frameCount/1.5
  a = 30*cos(t)+10;
  b = 30*sin(t)*cos(t)+20
  c = 40*cos(t)+30*sin(t)*cos(t)
  centerP()
  sideP()
  push()
  rotate(90)
  sideP()
  pop()
  
  
}

function shapeD(){
  fill(0,50,100,10);
  beginShape()
    for (let i=0;i<360;i++){
      x=a*sin(i)*cos(i)+b*sin(i);
      y = c*cos(i)
      vertex(x,y/cos(t))
    }
  endShape(CLOSE)
  fill(55,155,85,10);
  beginShape()
    for (let i=0;i<360;i++){
      x=a*sin(i)*cos(i)+b*sin(i);
      y = c*cos(i)
      vertex(x*sin(t),y/cos(t))
    }
  endShape(CLOSE)
  fill(0,50,70,10)
  beginShape()
    for (let i=0;i<360;i++){
      x=a*sin(i)*cos(i)+b*sin(i);
      y = c*cos(i)
      vertex(x*sin(t)/2,y/cos(t))
    }
  endShape(CLOSE)
}
function centerP(){
  rotate(90)
  rotate(frameCount)
  push()
  translate(0,-50)
  shapeD()
  pop()
  push()
  translate(0,50)
  rotate(180)
  shapeD()
  pop()
}

function sideP(){
  push()
  translate(-width*sin(t)/5,-width*sin(t)/5)
  centerP()
  pop()
  push()
  translate(width*sin(t)/5,width*sin(t)/5)
  centerP()
  pop()
}