Hi there!
I’m workiung with the following code in p5js to make an animation of ellipses (raindrops). In the end I want to loop my video (screen recording). So the positions of the ellipses have to be in the same position after 8 sec as they are in the beginning… As the position of the ellipses are random, I want to repeat those random positions after 8 seconds. I tried to work with randomSeed(), but it did not work somehow.
code:
</>
let drops = []; // group of Drop
function setup() {
createCanvas(windowWidth, windowHeight);
//stroke(255);
noFill();
}
function draw() {
background(0, 0, 0, 20);
if(frameCount % 3 == 0) { //every 3th frame
//drops.push(new Drop(mouseX, mouseY));
drops.push(new Drop(random(width), random(height)));
}
for(d of drops) {
d.display();
d.grow();
}
}
//function mouseDragged() {
// drops.push(new Drop(mouseX, mouseY));
//}
class Drop {
constructor(xPos, yPos) { //initialize class
this.xPos = xPos;
this.yPos = yPos;
this.size = 0;
this.sizeMax = random(100, 200);
this.fc = 0; // custom framecount
this.stroke = 255;
}
display() {
stroke(255);
ellipse(this.xPos, this.yPos, this.size);
}
grow() {
this.size = sin(this.fc * .015) * this.sizeMax;
this.fc++; // grow by 1
if(this.size >= this.sizeMax - 1) {
this.remove();
}
}
remove() {
drops.splice(drops.indexOf(this), 1);
}
}
</>
I’d be very thankful if someone could help me