now I have the image on the grid with a sequence. I want to know how to put the image in a random position.
Link: p5.js Web Editor
let imgs = ;
function preload() {
for (let i = 1; i < 10; i++) {
imgs[i] = loadImage(i + “.jpg”);
}
}function setup() {
createCanvas(400, 400);
background(255);
}function draw() {
let cx = floor(mouseX / (width / 3));
let cy = floor(mouseY / (height / 3));
for (let x = 0; x < 3; x++) {
for (let y = 0; y < 3; y++) {
for (let z = 1; z <= x+y*3+1 ; z++) {
rect((x * width) / 3, (y * height) / 3, width / 3, height / 3);
if (cx == x && cy == y) {
image(
imgs[z],
(x * width) / 3 + 1,
(y * height) / 3 + 1,
width / 3,
height / 3
);
}
}
}
}
}