let a, b, c, d, m1, x1, y1, r2, g2, b2;
let nRot;
function setup() {
cnv = createCanvas(windowWidth * 0.9, windowHeight * 0.9);
rectMode(CENTER);
nRot = int(random(5, 16));
a = width / 6;
b = height / 6;
c = random(-3, 3.1);
d = random(-3, 3.1);
x1 = random(width);
y1 = random(height);
r2 = random(150, 255);
g2 = random(150, 255);
b2 = random(150, 255);
background(r2 / 5, g2 / 5, b2 / 5);
}
function draw() {
translate(width / 2, height / 2);
angleMode(DEGREES);
background(r2 / 5, g2 / 5, b2 / 5, 2);
stroke(r2, g2, b2, 50);
if (width < 400) {
strokeWeight(0.25);
} else {
strokeWeight(0.5);
}
a1 = a;
b1 = b;
c1 = c;
d1 = d;
for (let i = 0; i < 1000; i++) {
x = a1 * sin(x1 * d1 - a1 * y1) - (a1 / 2) * cos(x1 * c1);
y = b1 * cos(x1 * d1) * sin(c1 + x1);
m1 = 1.5 - (1 * dist(x, y, 0, 0)) / (width / 2);
stroke(r2 * m1, g2 * m1, b2 * m1);
for (let j = 0; j < nRot; j++) {
push();
rotate((360 / nRot) * j);
point(x, y);
pop();
}
x1 = x;
y1 = y;
}
border();
}
function border() {
noFill();
stroke(r2 / 6, g2 / 6, b2 / 6);
strokeWeight(4);
rect(0, 0, width - 20, height - 20);
}
function mousePressed() {
setup();
}
function keyPressed() {
save(cnv, "fleur", "png");
}
function windowResized() {
setup();
resizeCanvas(windowWidth * 0.9, windowHeight * 0.9);
}