File Listing Order


#41

Docs.Oracle.com/en/java/javase/11/docs/api/java.base/java/util/Arrays.html#sort(java.lang.Object[])

static final String PICS_EXTS = "extensions=,png,jpg,jpeg,gif,tif,tiff,tga,bmp,wbmp";

static final float FPS = .25;

PImage[] images;

void setup() {
  size(1200, 600);
  frameRate(FPS);
  imageMode(CENTER);

  final File dir = dataFile("");
  println(dir);

  String[] imagePaths = {};
  int imagesFound = 0;

  if (dir.isDirectory()) {
    imagePaths = listPaths(dir.getPath(), "files", "recursive", PICS_EXTS);
    imagesFound = imagePaths.length;
    java.util.Arrays.sort(imagePaths); // sorts the array in place
  }

  printArray(imagePaths);
  println("Found", imagesFound, "image(s)");

  for (int i = 0; i < imagesFound; images[i] = loadImage(imagePaths[i++]));
}

void draw() {
  clear();
  image(images[frameCount % images.length], width>>1, height>>1);
}

#42

Yeah, I mentioned it in the first reply to this topic, and even you in the second reply…

I feel like this topic may or may not have went for WAY too long than needed and we are just kind of repeating ourselves here… :smiley: