fractalkitty looking for math? fractalkitty.com

100 days of code

petriDish

#trig#animation

portHole

function setup(){
  createCanvas(600,600);
  noStroke();
  
}

function draw(){
  angleMode(RADIANS)
  noStroke();
  background(100,120,140);
  t=frameCount/100;
  translate(width/2, height/2);
  push()
  rotate(-t)
  translate(50*cos(t)*sin(t),100*sin(t))
  for (let i=0; i<20;i++){
    fill(100-i*2,120-i*2,140-i*2,20);
    circle(0,0,200-10*i)
  }
  pop()
  push()
  rotate(t)
  translate(-200*cos(t)*sin(t),-150*sin(t))
  for (let i=0; i<20;i++){
    fill(100-i*2,120-i*2,140-i*2,20);
    circle(0,0,200-10*i)
  }
  pop()
  push()
  rotate(-t)
  translate(100*cos(t)-50*sin(t/2),200*sin(t))
  for (let i=0; i<20;i++){
    fill(100-i*2,120-i*2,140-i*2,20);
    circle(0,0,200-10*i)
  }
  pop()
  push()
  rotate(t)
  translate(-190*cos(t)*sin(t),-100*sin(t))
  for (let i=0; i<20;i++){
    fill(100-i*2,120-i*2,140-i*2,20);
    circle(0,0,200-10*i)
  }
  pop()
  push()
  rotate(t)
  translate(-90*cos(t)*sin(t),-200*sin(t))
  for (let i=0; i<20;i++){
    fill(100-i*2,120-i*2,140-i*2,20);
    circle(0,0,200-10*i)
  }
  pop()
  push()
  rotate(-t)
  translate(-100*cos(t)*sin(t),-150*cos(t))
  for (let i=0; i<20;i++){
    fill(100-i*2,120-i*2,140-i*2,20);
    circle(0,0,200-10*i)
  }
  pop()
  push()
  rotate(t)
  translate(-200*cos(t)*sin(t),-90*cos(2*t))
  for (let i=0; i<20;i++){
    fill(100-i*2,120-i*2,140-i*2,20);
    circle(0,0,200-10*i)
  }
  pop()
  push()
  rotate(-t)
  translate(-200*cos(t)-50*sin(t/3),190*cos(t)+50*sin(t/2))
  for (let i=0; i<20;i++){
    fill(100-i*2,120-i*2,140-i*2,20);
    circle(0,0,200-10*i)
  }
  pop()
  portHole();
}

function portHole(){
  push()
  angleMode(DEGREES)
  fill(0)
  beginShape()
    for (let i=0; i <= 180; i++) {
      x = 280*cos(i)
      y = 280*sin(i);
      vertex(x,y) 
  }
  vertex(-width/2,0)
  vertex(-width/2, height/2);
  vertex(width/2, height/2);
  vertex(width/2,0)
  endShape(CLOSE);
  beginShape()
    for (let i=180; i <= 360; i++) {
      x = 280*cos(i)
      y = 280*sin(i);
      vertex(x,y) 
  }
  vertex(width/2,0)
  vertex(width/2, -height/2);
  vertex(-width/2, -height/2);
  vertex(-width/2,0)
  endShape(CLOSE);
  stroke(4, 112, 179);
  strokeWeight(1)
  noFill()
  pop()
}