let playBool = true;
let a, b, c, d;
function setup() {
createCanvas(windowWidth, windowHeight);
background(100);
background(random(0, 30));
angleMode(DEGREES);
colorMode(HSB, 100);
a = random(1, 5);
b = random(-5, 5);
c = random(2, 5);
d = random(1, 5);
}
function draw() {
if (!playBool) {
frameCount--;
} else {
translate(width / 2, height / 2);
t = frameCount / 20;
triDraw();
}
}
function triDraw() {
fill(mouseX / 4, mouseY, 255, 2);
x = (width / 2) * cos(t * b) - (width / 3) * sin(t / c);
y = (height / 2) * sin(t / a) + (height / 3) * sin(t / c);
x1 = (width / 2) * cos(t / c) * sin(t * a) - (width / 3) * tan(t / d);
y1 = (height / 2) * cos(t / a) - (height / 2) * cos(t);
stroke(
50 + 50 * sin(y / 4) * sin(y / 4),
50 + 50 * cos(y / 3) * cos(y / 3),
100,
10
);
line(x, y, x1, y1);
line(x, y, -x1, -y1);
line(x, y, -x1, y1);
line(x, y, x1, -y1);
}
function mousePressed() {
playBool = !playBool;
a = random(1, 5);
b = random(-5, 5);
c = random(2, 5);
d = random(1, 5);
}