Skip to content

Instantly share code, notes, and snippets.

@robinvanemden
Last active July 15, 2018 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robinvanemden/6a25cac6aa3fe4e574eb65f9c852b7fd to your computer and use it in GitHub Desktop.
Save robinvanemden/6a25cac6aa3fe4e574eb65f9c852b7fd to your computer and use it in GitHub Desktop.
Quick and easy multi monitor (1080p) multi photo slideshow in Processing 3.0
int screen_height = 1920;
int screen_width = 1080;
int image_width = 1080;
int image_height = 1350;
int top_bottom = (screen_height - image_height) / 2;
int top_bottom_border = 30;
int local_test = 1;
int local_div = 3;
String[] filenames;
void setup() {
if (local_test == 1) {
screen_height = screen_height / local_div;
screen_width = screen_width / local_div;
image_width = image_width / local_div;
image_height = image_height / local_div;
top_bottom = (screen_height - image_height) / 2;
top_bottom_border = top_bottom_border / local_div;
}
noCursor();
fullScreen(SPAN);
//fullScreen(1); // for single screen span
background(0);
noStroke();
fill(102);
String path = sketchPath("images");
filenames= listFileNames(path);
//printArray(filenames);
noLoop();
}
String getRandomImage() {
int index = int(random(filenames.length));
String img_string = "images/"+filenames[index];
return img_string;
}
void mousePressed() {
redraw();
}
void draw() {
PImage img1 = loadImage(getRandomImage());
PImage img2 = loadImage(getRandomImage());
PImage img3 = loadImage(getRandomImage());
PImage img4 = loadImage(getRandomImage());
PImage img5 = loadImage(getRandomImage());
PImage img6 = loadImage(getRandomImage());
PImage img7 = loadImage(getRandomImage());
PImage img8 = loadImage(getRandomImage());
PImage img9 = loadImage(getRandomImage());
img1.resize(image_width, image_height);
image(img1, 0, top_bottom);
img2.resize(image_width, image_height);
image(img2, screen_width, top_bottom);
img3.resize(image_width, image_height);
image(img3, screen_width*2, top_bottom);
// top images
img4.resize(image_width, image_height);
image(img4, 0, top_bottom - image_height - top_bottom_border);
img5.resize(image_width, image_height);
image(img5, screen_width, top_bottom - image_height -top_bottom_border);
img6.resize(image_width, image_height);
image(img6, screen_width*2, top_bottom - image_height - top_bottom_border);
// top images
img7.resize(image_width, image_height);
image(img7, 0, top_bottom + image_height + top_bottom_border);
img8.resize(image_width, image_height);
image(img8, screen_width, top_bottom + image_height + top_bottom_border);
img9.resize(image_width, image_height);
image(img9, screen_width*2, top_bottom + image_height + top_bottom_border);
if(local_test == 1) {
fill(0);
rect(0,screen_height,screen_width*3,screen_height);
}
}
String[] listFileNames(String dir) {
File file = new File(dir);
if (file.isDirectory()) {
String names[] = file.list();
return names;
} else {
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment