Skip to content

Instantly share code, notes, and snippets.

@yoggy
Created October 29, 2013 07:04
Show Gist options
  • Select an option

  • Save yoggy/7210199 to your computer and use it in GitHub Desktop.

Select an option

Save yoggy/7210199 to your computer and use it in GitHub Desktop.
import java.io.*;
PImage [] imgs;
void setup() {
size(1200, 800);
File folder = new java.io.File(dataPath(""));
FilenameFilter jpgFilter = new java.io.FilenameFilter() {
public boolean accept(File dir, String name) {
return name.toLowerCase().endsWith(".jpg");
}
};
String[] filenames = folder.list(jpgFilter);
//
imgs = new PImage[filenames.length];
for (int i = 0; i < filenames.length; ++i) {
println("filenames[" + i + "]=" + filenames[i]);
imgs[i] = loadImage(filenames[i]);
imgs[i].resize(120, 80);
}
}
void draw() {
int x = 0, y = 0;
for (int i = 0; i < imgs.length; ++i) {
image(imgs[i], x, y);
x += imgs[i].width;
if (x >= width) {
x = 0;
y += imgs[i].height;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment