p5((s) => {
let w = 1080 / 2;
let h = 1920 / 2;
let cw = 10;
let ch = 30;
let frames = 500;
let noiseScaleSpace = 0.0003;
let noiseScaleTime = 0.1;
s.setup = function () {
s.createCanvas(w, h);
s.frameRate(5);
s.pixelDensity(2);
s.noLoop();
};
s.draw = function () {
s.clear();
s.background("white");
s.fill("white");
s.stroke("black");
s.strokeWeight(2);
for (let x = 0; x < w; x += cw) {
for (let y = 0; y < h; y += ch) {
s.translate(x, y);
s.rotate(
s.noise(
x * noiseScaleSpace,
y * noiseScaleSpace,
s.sin(s.map(s.frameCount, 0, frames, 0, s.PI)) * noiseScaleTime
) * 1360
);
s.circle(ch / 2, cw - 5, 4);
s.resetMatrix();
}
}
if (s.frameCount > 1) {
s.saveCanvas(`image-${s.frameCount - 1}`, "png");
}
if (s.frameCount >= frames) {
s.noLoop();
}
};
s.mouseClicked = function () {
if (s.mouseX >= 0 && s.mouseX < w && s.mouseY >= 0 && s.mouseY < h) {
s.loop();
}
};
})