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
images[i] = loadImage(i + ".png");
// 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
Please note that this article is still in development Please note: This article may be very time-bound and the items […]
After a long period of work, about a dozen discarded lessons, and many discussions with a wide variety of people, […]
How do you develop a course for a subject as abstract and multifaceted as the topic of grid systems? Either […]
[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 […]
Hey people, I hope you are all well! I escaped the cold and wet weather in Germany and am now […]
Hey everyone, I hope you are well! Today I would like to talk about a problem in the sketching process. […]