Hi there. I have a question about a sketch i’m working on. I have it working the way I want it to, but, I want to change the amount of images that are displayed randomly from the array. It seems to currently display around 5, and i’m not sure where this is being stipulated in the code and where to change it. I’d like to set the display of the images to 10 random ones from the array. Any help / guidance would be greatly appreciated. Working code below. Thank you
PImage images;
void setup() {
frameRate(1);
size(800, 800);
images = new PImage[32]; // Create an array of 32 images
for (int i = 0; i < images.length; i++) {
images[i] = loadImage( i + “.png”); // Load each image from a file
}
}
void draw() {
background(255);
blendMode(MULTIPLY);
shuffleArray(images); // Shuffle the array of images
for (int i = 0; i < images.length; i++) {
image(images[i], i * random(width), random(height)); // Display each image in a row
}
}
void shuffleArray(PImage array) {
for (int i = array.length - 1; i > 0; i–) {
int j = (int) random(i + 1); // Generate a random index
// Swap the elements at indices i and j
PImage temp = array[i];
array[i] = array[j];
array[j] = temp;
}
}
void keyPressed() {
if (key == ‘s’) {
println(“Saving…”);
saveFrame(“screen-####.jpg”);
println(“Done saving.”);
noLoop();
}
}