p5((s) => {
let w = 1080 / 2;
let h = 1920 / 2;
let cw = 20;
let ch = 20;
let frames = 100
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("black");
s.fill("white");
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
) * 180
);
s.circle(ch / 2, cw - 5, 20);
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()
}
}
})