let piPic;
function preload() {
piPic=loadImage('/assets/pipic.png');
}
let a=4,b=10,c=0;
function setup() {
createCanvas(500, 500);
stroke(255);
noFill();
angleMode(DEGREES);
}
function draw() {
background(0);
w1=width/2
pi1()
pi2()
pi3()
pi4()
}
function pi1(){
push();
translate(w1/2,w1/2);
t=frameCount/2;
strokeWeight(0.5)
for(let j=0;j<360;j=j+3){
push()
rotate(j)
beginShape()
for(let i=0;i<w1/2;i++){
x=i
y=a*cos(2*i*b/a)
vertex(x,y)
}
endShape()
pop()
}
a=w1/2*sin(t/2)
b=w1/3*cos(t/2)
image(piPic,-w1/2,-w1/2,w1,w1)
circleWindow()
pop()
}
function pi2(){
push();
translate(3*w1/2,3*w1/2);
fill(0)
rect(-w1/2,w1/2,w1,w1)
noFill()
strokeWeight(0.1)
t=frameCount;
for(let i=0;i<360;i++){
x=90*cos(i)
y=40*sin(i)*cos(t)
circle(x,y,100)
}
image(piPic,-w1/2,-w1/2,w1,w1)
circleWindow()
pop()
}
function pi3(){
push();
translate(3*w1/2,w1/2);
fill(0)
rect(-w1/2,-w1/2,w1,w1)
fill(255,255,255,15)
strokeWeight(1)
t=frameCount;
for(let i=0;i<12;i++){
push()
rotate(i*36)
circle(0,40,160*sin(t/2));
pop()
}
image(piPic,-w1/2,-w1/2,w1,w1)
circleWindow()
pop()
}
function pi4(){
push();
translate(w1/2,3*w1/2);
fill(0)
rect(-w1/2,-w1/2,w1,w1)
fill(255,255,255,15)
strokeWeight(1)
t=frameCount;
for(let i=0;i<22;i++){
push()
rotate(i*36)
circle(0,0,i*10-20*sin(t));
pop()
}
image(piPic,-w1/2,-w1/2,w1,w1)
circleWindow()
pop()
}
function circleWindow(){
m=w1/2-5
fill(0)
beginShape()
for (let i=0; i <= 180; i++) {
x = m*cos(i)
y = m*sin(i);
vertex(x,y)
}
vertex(-w1/2,0)
vertex(-w1/2, w1/2);
vertex(w1/2, w1/2);
vertex(w1/2,0)
endShape(CLOSE);
beginShape()
for (let i=180; i <= 360; i++) {
x = m*cos(i)
y = m*sin(i);
vertex(x,y)
}
vertex(w1/2,0)
vertex(w1/2, -w1/2);
vertex(-w1/2, -w1/2);
vertex(-w1/2,0)
endShape(CLOSE);
stroke(255, 255, 255);
strokeWeight(1)
noFill()
circle(0,0,w1)
}