let img1, img2;
let m;
let lineGroup1;
let nSymmetry;
function preload() {
img1 = loadImage("/assets/power.jpg");
img2 = loadImage("/assets/star.png");
}
function setup() {
createCanvas(600, 600);
strokeWeight(0.25);
angleMode(DEGREES);
stroke(255);
imageMode(CENTER);
noLoop();
t = floor(random(0, 3.99));
}
function draw() {
translate(width / 2, height / 2);
image(img1, 0, 0, 600, 600);
nStars = pow(10, 2);
for (let i = 0; i < nStars; i++) {
s = randomGaussian(10, 20);
tr = randomGaussian(0, width / 2);
ang = random(0, 360);
image(img2, tr * cos(ang), -width / 4 + tr * sin(ang), s, s);
}
for (let i = 0; i < nStars * 2; i++) {
s = 5 + random(0, 4);
tr = random(0, width);
ang = random(0, 360);
image(
img2,
random(-width / 2, width / 2),
random(-width / 2, width / 2),
s,
s
);
}
image(img2, 0, -width / 4, 200, 200);
nPoppy = width;
for (let i = 0; i < nPoppy; i++) {
push();
x = random(-width / 2 - i / 2, width / 2 + i / 2);
y = random(i - 20, i + 20);
if (t === 0) {
rotate((x * 360) / width / 10);
} else if (t === 1) {
rotate((x * 360) / width / 2);
} else if (t === 2) {
rotate((x * 360) / width);
} else if (t === 3) {
rotate(0);
}
translate(x, y - 100);
scale(0.2 + y / width / 1.5);
poppy();
pop();
}
}
function poppy() {
n = floor(random(1, 2.2));
a = 200;
if (n == 1) {
fill(141, 184, 132, a);
x = 0;
y = 0;
noStroke();
tmp = random(-100, 100);
for (let i = 0; i < height / 2; i++) {
circle(x, y, 2);
x = x - tmp * sin(i / 500);
y = i;
}
fill(255, 255, 245, a);
petal();
push();
rotate(random(-40, 40));
fill(255, 255, 235, a);
petal();
pop();
}
if (n == 2) {
fill(141, 184, 132, a);
x = 0;
y = 0;
noStroke();
tmp = random(-100, 100);
for (let i = 0; i < height / 2; i++) {
circle(x, y, 2);
x = x - tmp * sin(i / 500);
y = i;
}
fill(255, 255, 245, a);
petal();
push();
rotate(random(-190, -170));
fill(255, 255, 235, a);
petal();
pop();
push();
rotate(random(-120, -50));
fill(255 + random(-10, 10), 255 + random(-5, 5), 235 + random(-20, 20), a);
petal();
pop();
push();
rotate(random(120, 50));
fill(255 + random(-10, 10), 255 + random(-5, 5), 235 + random(-20, 20), a);
petal();
pop();
push();
stroke(252, 251, 179);
for (let i = 0; i < 500; i++) {
stroke(200 + random(30, 60), 190 + random(30, 60), 129 + random(30, 60));
p = random(10, 20);
a = random(0, 360, a);
line(0, 0, p * cos(a), p * sin(a));
}
fill(150, 150, 90, a);
circle(0, 0, 5);
pop();
}
}
function petal() {
beginShape();
vertex(0, 0);
r = 50;
for (let i = 0; i < 100; i++) {
vertex(
r * cos(-160 + i) + 1 * cos(i * 50 + random(-100, 100)),
r * sin(-160 + i) + 1 * sin(i * 50 + random(-100, 100))
);
}
endShape();
circle(0, -5, 10);
push();
translate(10, -20);
rotate(-60);
ellipse(0, 0, r, 10);
pop();
push();
translate(-20, -8);
rotate(20);
ellipse(0, 0, r, 10);
pop();
}
function keyPressed() {
setup();
draw();
}
function mousePressed() {
setup();
draw();
}