let img1
let r = 150;
function preload() {
img1 = loadImage("/assets/hierarchy.jpg");
}
function setup() {
createCanvas(600, 600);
noStroke()
}
function draw() {
t = frameCount/200 ;
translate(width/2,height/2);
push()
rotate(-t/10)
translate(-350,-350)
image(img1,0,0,700,700)
pop()
push()
translate(r*sin(t)*cos(-t),r*(cos(t)*sin(t)))
rotate(t/3)
scale(1.5)
translate(10,-60)
push()
fill(20*abs(cos(t)),150*abs(cos(t)),190*abs(cos(t)),10+200*cos(t/2)*cos(t/2))
translate(r*pow(sin(t),4)-r/4*cos(t/2)*pow(sin(t),5),r*cos(t)*pow(sin(t),4))
beginShape()
vertex(-20,0)
vertex(0,0)
vertex(50,50*sqrt(3))
vertex(-28,50*sqrt(3))
vertex(-18,50*sqrt(3)-10*sqrt(3))
vertex(20,50*sqrt(3)-10*sqrt(3))
endShape()
pop()
push()
fill(10*abs(cos(t)),60*abs(cos(t)),90*abs(cos(t)),10+200*cos(t/2)*cos(t/2))
translate(-r*pow(sin(t),4),r*cos(t)*pow(sin(t),4))
beginShape()
translate(-70,88)
rotate(PI/3*4)
vertex(-20,0)
vertex(0,0)
vertex(50,50*sqrt(3))
vertex(-28,50*sqrt(3))
vertex(-18,50*sqrt(3)-10*sqrt(3))
vertex(20,50*sqrt(3)-10*sqrt(3))
endShape()
pop()
push()
fill(150*abs(cos(t)),220*abs(cos(t)),255*abs(cos(t)),10+200*cos(t/2)*cos(t/2))
translate(-r*pow(sin(t),4),-r*cos(t)*pow(sin(t),4)+r*pow(sin(t),4))
beginShape()
translate(41,105)
rotate(-PI/3*4)
vertex(-20,0)
vertex(0,0)
vertex(50,50*sqrt(3))
vertex(-28,50*sqrt(3))
vertex(-18,50*sqrt(3)-10*sqrt(3))
vertex(20,50*sqrt(3)-10*sqrt(3))
endShape()
pop()
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()
angleMode(RADIANS)
pop()
}