p5((s) => {
let image;
s.preload = function () {
image = s.loadImage(imageURL);
};
s.setup = function () {
s.createCanvas(width, height);
image.resize(width, height);
};
s.draw = function () {
for (let index = 0; index < 30; ++index) {
let x1 = s.random(image.width);
let y1 = s.random(image.height);
let x2 = x1 + s.random(-5, 5);
let y2 = y1 + s.random(-5, 5);
let fragmentWidth = 5;
let fragmentHeight = s.random(-400, 400);
let source = [x1, y1, fragmentWidth, fragmentHeight];
let target = [x2, y2, fragmentWidth, fragmentHeight];
image.copy(image, ...source, ...target);
s.image(image, 0, 0);
s.noFill();
s.stroke("blue");
s.rect(x2, y2, fragmentWidth, fragmentHeight);
}
};
})