initial commit
This commit is contained in:
96
scancropper2.pde
Normal file
96
scancropper2.pde
Normal file
@@ -0,0 +1,96 @@
|
||||
import drop.*;
|
||||
|
||||
SDrop drop;
|
||||
Bounder bounder;
|
||||
int imageNo = 0;
|
||||
int imageAmount;
|
||||
String[] imageList;
|
||||
PImage[] images;
|
||||
boolean imageLoaded;
|
||||
String folderURI;
|
||||
|
||||
void setup() {
|
||||
size(240, 100);
|
||||
frameRate(30);
|
||||
drop = new SDrop(this);
|
||||
surface.setResizable(true);
|
||||
bounder = new Bounder();
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(255);
|
||||
fill(0);
|
||||
text("Drop image folder here", 52, 53, 20);
|
||||
|
||||
if (imageLoaded) {
|
||||
if (images[imageNo] != null) {
|
||||
image(images[imageNo], 0, 0, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
bounder.update();
|
||||
bounder.display();
|
||||
}
|
||||
|
||||
void keyPressed() {
|
||||
if (key == ENTER) {
|
||||
if (bounder.state >= 3) {
|
||||
println("Compiling images");
|
||||
bounder.compile();
|
||||
println("Compiling finished, reset bounder");
|
||||
//bounder.state = 0;
|
||||
}
|
||||
}
|
||||
if (key == ' ') {
|
||||
bounder.state = 0;
|
||||
println("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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void mousePressed() {
|
||||
bounder.click();
|
||||
}
|
||||
|
||||
void setImage(int i) {
|
||||
imageLoaded = false; //seperate threat not present ladida
|
||||
images[i] = loadImage(imageList[imageNo]);
|
||||
imageLoaded = 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);
|
||||
imageAmount = droppedFiles.length-1; // assuming all files in folder are images
|
||||
images = new PImage[imageAmount];
|
||||
imageList = new String[imageAmount];
|
||||
for (int i = 0; i < imageAmount; i++) {
|
||||
imageList[i] = droppedFiles[i].toString();
|
||||
}
|
||||
imageList = sort(imageList);
|
||||
setImage(imageNo);
|
||||
/*for (int i = 0; i < imageAmount; i++) {
|
||||
images[i] = loadImage(droppedFiles[i].toString());
|
||||
println("hi");
|
||||
} // braucht zu lang die scheisse */
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user