# Random Collage Generator

``````// Declare and initialize and array of images
PImage[] images = new PImage[15];

void setup() {
size(900, 900);

// Slow down the whole thing
frameRate(1);

// Load images to the array
for (int i = 0; i < images.length; i++) {
// Load the specific image to the slot in the array

// resize that image
images[i].resize(2000, 0);

// Apply a grayscale filter to the image
images[i].filter(GRAY);
}

// center images and rectangles
rectMode(CENTER);
imageMode(CENTER);
}

void draw() {
background(#f1f1f1);

// create a red ellipse at the center of the background
fill(#ff0000);
noStroke();
ellipse(width/2, height/2, 700, 700);

for (int i = 0; i < images.length; i++) {

// Get the specific image
PImage img = images[i];

// set random x and y positions
float x = random(width);
float y = random(height);

// decide how large the image shall be
float scalar = random(0.1, 0.5);

// place the image with a probability of 50%
if (random(1) < 0.5) {

// place the image
push();
translate(x, y);
scale(scalar);
image(img, 0, 0);
pop();
}
}
}
``````

## Related

Processing and p5.js compared

New course out now: Grid Systems

After a long period of work, about a dozen discarded lessons, and many discussions with a wide variety of people, […]

A brief research on grid systems

How do you develop a course for a subject as abstract and multifaceted as the topic of grid systems? Either […]

Student Journey – with Lily Montague

[INTROTEXT VON TIM HIER EINFÜGEN] What sparked your interest in creative coding and how did you get started? For me, […]

Imagine if the majority of all outdoor displays in public spaces were broadcasting the best of design and moving image […]

The Magic Triangle

Hey people, I hope you are all well! I escaped the cold and wet weather in Germany and am now […]

How to build the folder structure?

Hey everyone, I hope you are well! Today I would like to talk about a problem in the sketching process. […]