import drop.*; SDrop drop; Bounder bounder; int imageNo = 0; int imageAmount; ArrayList covers = new ArrayList(); String[] imagePaths; PImage[] images; PImage imageThumb; boolean imageLoaded; String folderURI; PShape COVER; void setup() { size(240, 100); frameRate(30); noSmooth(); COVER = createShape(); drop = new SDrop(this); surface.setResizable(true); bounder = new Bounder(); noLoop(); } void draw() { background(255); fill(0); text("Drop image folder here", 52, 53, 20); if (imageLoaded) { if (images[imageNo] != null) { image(imageThumb, 0, 0, width, height); } } for (int i = 0; i < covers.size(); i++) { Cover c = covers.get(i); shape(c.coverRect); } bounder.update(); bounder.display(); } void keyPressed() { if (key == ENTER) { if (bounder.state >= 3) { println("Compiling images"); bounder.compile(true); println("Compiling finished, reset bounder"); //bounder.state = 0; } } if (key == ' ') { if (bounder.state == 3) bounder.compile(false); bounder.reset(); } if (key == CODED) { if (keyCode == RIGHT) { imageNo++; if (imageNo > imageAmount) imageNo = imageAmount; else setImage(imageNo); println(imageNo); } else if (keyCode == LEFT) { imageNo--; if (imageNo < 0) imageNo = 0; else setImage(imageNo); println(imageNo); } } redraw(); } void mousePressed() { if(mouseButton == LEFT){ bounder.leftclick(); } if(mouseButton == RIGHT){ bounder.rightclick(); } } void setImage(int i) { images[i] = loadImage(imagePaths[i]); imageThumb = images[i].get(); imageThumb.resize(images[i].width/7, images[i].height/7); imageLoaded = true; redraw(); } boolean firstDrop = true; void dropEvent(DropEvent theDropEvent) { if (theDropEvent.isFile()) { File myFile = theDropEvent.file(); if (myFile.isDirectory()) { File[] droppedFiles = myFile.listFiles(); println(droppedFiles); folderURI = droppedFiles[0].getParent(); println(folderURI); for (int i = covers.size(); i-- != 0; covers.remove(i)); ArrayList imgs = new ArrayList(); imageNo = 0; imageAmount = 0; for (int i = 0; i < droppedFiles.length; i++) { String fn = droppedFiles[i].toString().toLowerCase(); if (fn.endsWith(".jpg") || fn.endsWith(".jpeg") || fn.endsWith(".bmp") || fn.endsWith(".png") || fn.endsWith(".gif")) imgs.add(droppedFiles[i].toString()); } imageAmount = imgs.size(); imagePaths = new String[imageAmount]; imagePaths = imgs.toArray(imagePaths); imagePaths = sort(imagePaths); images = new PImage[imageAmount]; if (imageNo++ <= imageAmount) imageNo++; //open on page 2 setImage(imageNo); if (firstDrop) { surface.setSize(displayWidth, displayHeight); firstDrop = false; } } } }