diff --git a/bounder.pde b/bounder.pde index eaea9c6..1ef7d19 100644 --- a/bounder.pde +++ b/bounder.pde @@ -13,14 +13,14 @@ class Bounder { if (state < 4) state++; if (state == 1) { p1 = new PVector(mouseX, mouseY); + loop(); } if (state == 2) { p2 = new PVector(mouseX, mouseY); } if (state == 3) { h = -p2.dist(new PVector(mouseX, mouseY)); - - + noLoop(); } } void update() { diff --git a/scancropper2.pde b/scancropper2.pde index 3305c9c..48dafb7 100644 --- a/scancropper2.pde +++ b/scancropper2.pde @@ -4,6 +4,8 @@ SDrop drop; Bounder bounder; int imageNo = 0; int imageAmount; + + String[] imagePaths; PImage[] images; PImage imageThumb; @@ -17,6 +19,7 @@ void setup() { drop = new SDrop(this); surface.setResizable(true); bounder = new Bounder(); + noLoop(); } void draw() { @@ -26,8 +29,7 @@ void draw() { if (imageLoaded) { if (images[imageNo] != null) { - // image(images[imageNo], 0, 0, width, height); - image(imageThumb, 0, 0, width, height); + image(imageThumb, 0, 0, width, height); } } @@ -45,7 +47,7 @@ void keyPressed() { } } if (key == ' ') { - if(bounder.state == 3) bounder.compile(false); + if (bounder.state == 3) bounder.compile(false); bounder.state = 0; println("Bounder reset"); } @@ -63,6 +65,7 @@ void keyPressed() { println(imageNo); } } + redraw(); } void mousePressed() { @@ -70,10 +73,11 @@ void mousePressed() { } void setImage(int i) { - images[i] = loadImage(imagePaths[imageNo]); + images[i] = loadImage(imagePaths[i]); imageThumb = images[i].get(); imageThumb.resize(images[i].width/7, images[i].height/7); imageLoaded = true; + redraw(); } void dropEvent(DropEvent theDropEvent) { @@ -85,12 +89,12 @@ void dropEvent(DropEvent theDropEvent) { println(droppedFiles); folderURI = droppedFiles[0].getParent(); println(folderURI); - + ArrayList imgs = new ArrayList(); 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")) + if (fn.endsWith(".jpg") || fn.endsWith(".jpeg") || fn.endsWith(".bmp") || fn.endsWith(".png") || fn.endsWith(".gif")) imgs.add(droppedFiles[i].toString()); } imageAmount = imgs.size(); @@ -98,8 +102,9 @@ void dropEvent(DropEvent theDropEvent) { imagePaths = imgs.toArray(imagePaths); imagePaths = sort(imagePaths); images = new PImage[imageAmount]; + if(imageNo++ <= imageAmount) imageNo++; //open on page 2 setImage(imageNo); - + surface.setSize(displayWidth, displayHeight); } } }