p5((sketch) => {
const side = 500;
const numFrames = 60;
const margin = 5;
sketch.setup = function () {
sketch.createCanvas(side, side);
};
function periodicFunction(p, seed, x, y) {
let radius = 1.3;
let scl = 0.018;
return (
1.0 *
Noise4D(
seed + radius * sketch.cos(sketch.TWO_PI * p),
radius * sketch.sin(sketch.TWO_PI * p),
scl * x,
scl * y
)
);
}
function offset(x, y) {
return 0.015 * sketch.dist(x, y, sketch.width / 2, sketch.height / 2);
}
sketch.draw = function () {
const m = 450;
sketch.background(0);
let t = (1.0 * (sketch.frameCount - 1)) / numFrames;
sketch.stroke(255, 50);
sketch.strokeWeight(1.5);
for (let i = 0; i < m; i++) {
for (let j = 0; j < m; j++) {
let x = sketch.map(i, 0, m - 1, margin, sketch.width - margin);
let y = sketch.map(j, 0, m - 1, margin, sketch.height - margin);
let dx = 20.0 * periodicFunction(t - offset(x, y), 0, x, y);
let dy = 20.0 * periodicFunction(t - offset(x, y), 123, x, y);
sketch.point(x + dx, y + dy);
}
}
};
})