Preview: When Computers create Collages
2023-12-01 Today I want to share with you a first prototype that will be the basis for a new course that will probably be called “When Computers create Collages”. In this application, a stack of images is loaded and transformed into any number of computer-generated collages.









int amount = int(random(5, 25));
PGraphics[] layers = new PGraphics[amount];
PGraphics[] masks = new PGraphics[amount];
import java.io.File;
String [] imageFileNames;
StringList images;
void setup() {
size(1200, 900);
java.io.File folder = new java.io.File(dataPath("images"));
imageFileNames = folder.list();
images = new StringList();
println("loading...");
// Load the image-files and push thems to imagess-arrayList
for (int i = 0; i < imageFileNames.length; i++) {
String filename = imageFileNames[i];
if (filename.indexOf("Store") == -1) {
images.push("data/images/"+filename);
}
}
println(images.size() + " images loaded!");
for (int i = 0; i < layers.length; i++) {
layers[i] = createGraphics(width, height);
masks[i] = createGraphics(width, height);
}
}
PGraphics l, m;
PImage img;
void draw() {
amount = int(random(3, 30));
background(0);
//blendMode(SCREEN);
for (int i = 0; i < layers.length; i++) {
l = layers[i];
img = loadImage(images.get(int(random(images.size()))));
img.resize(width, 0);
l.beginDraw();
l.clear();
l.push();
l.image(img, 0, 0);
l.pop();
l.endDraw();
m = masks[i];
m.beginDraw();
m.background(#FFFFFF);
m.noStroke();
m.fill(0);
m.beginShape();
for (int j = 0; j < 12; j++) {
float x = random(-width, width*2);
float y = random(-height, height*2);
m.curveVertex(x, y);
}
m.endShape();
if (random(1) < 0.1) {
m.circle(random(width), random(height), random(width/2));
}
m.endDraw();
l.mask(m);
image(l, 0, 0);
}
saveFrame("out/###.png");
}
Enjoying the content?
Since 2018, I have published 239 interviews, case studies, and tutorials, along with over 345 lessons in 22 online courses – and there's more to come! If you want to get full access or simply support my work and help keep this platform thriving, please consider supporting me on Patreon. Thank you very much!

Related

Click here to login or connect!To view this content, you must be a member of Tim's Patreon at €7 or […]

For my students at Elisava, I have created a new version of my mockup-tool. You need two different files for […]

Click here to login or connect!To view this content, you must be a member of Tim's Patreon at €7 or […]

A few months ago I made a small app that allows you to create image collages with some kind of […]

Since the beginning of the Corona crisis, I have been more and more interested in the history of ancient philosophy. […]

Generative visuals made from the "Prelude in C" by Johann Sebastian Bach.

Click here to login or connect!To view this content, you must be a member of Tim's Patreon at €7 or […]