let t, n;
function setup() {
createCanvas(windowWidth, windowHeight);
noFill();
strokeWeight(0.07);
s = 0.07;
cnt = 0;
background(50, 50, 100);
n1 = [];
for (let n = 0; n < 10; n += s) {
n1[cnt] = 10 * random(0, 1);
cnt++;
}
}
function draw() {
translate(width / 2, height / 2);
scale(5);
background(50, 50, 100);
time = frameCount / 50;
cnt = 0;
for (let n = 0; n < 10; n += s) {
beginShape();
for (let t = -4 * PI; t <= 4 * PI; t += 0.05) {
p = sin(n1[cnt]);
stroke(15 * n1[cnt] + 50, 25 * n1[cnt] + 50, 20 * n1[cnt] + 50, 100);
r = 5 * n1[cnt] * pow(sin(t), p) + 2 * cos(n1[cnt] * t + time);
vertex(r * cos(t), r * sin(t));
}
endShape();
beginShape();
for (let t = -4 * PI; t <= 4 * PI; t += 0.05) {
p = sin(n1[cnt]);
stroke(15 * n1[cnt] + 50, 25 * n1[cnt] + 50, 20 * n1[cnt] + 50, 100);
r = 5 * n1[cnt] * pow(sin(t), p) + 2 * cos(n1[cnt] * t + time);
vertex(-r * cos(t), -r * sin(t));
}
endShape();
cnt++;
}
portHole();
}
function portHole() {
fill(50, 50, 100, 180);
stroke(50, 60, 80);
c1 = width / 4;
rd = c1 / 3;
beginShape();
for (let i = 0; i <= PI; i += 0.01) {
x = rd * cos(i);
y = rd * sin(i);
vertex(x, y);
}
vertex(-c1, 0);
vertex(-c1, c1);
vertex(c1, c1);
vertex(c1, 0);
endShape(CLOSE);
beginShape();
for (let i = PI; i <= TWO_PI; i += 0.01) {
x = rd * cos(i);
y = rd * sin(i);
vertex(x, y);
}
vertex(c1, 0);
vertex(c1, -c1);
vertex(-c1, -c1);
vertex(-c1, 0);
endShape(CLOSE);
noFill();
circle(0, 0, 2 * rd + 50);
}