Browse Source

added class to cover parts of image that were already cropped

master
Victor Giers 1 year ago
parent
commit
9e990c12ed
3 changed files with 44 additions and 7 deletions
  1. 16
    5
      bounder.pde
  2. 19
    0
      cover.pde
  3. 9
    2
      scancropper2.pde

+ 16
- 5
bounder.pde View File

@@ -10,7 +10,8 @@ class Bounder {
}
PVector p1, p2, p3, p4;
void click() {
if (state < 4) state++;
if (state < 3) state++;
else state = 1;
if (state == 1) {
p1 = new PVector(mouseX, mouseY);
loop();
@@ -39,8 +40,6 @@ class Bounder {
line(p1.x, p1.y, mouseX, mouseY);
}
if (state > 1) {
//stroke(1);
//line(p1.x, p1.y, p2.x, p2.y);
fill(0);
noStroke();
circle(p2.x, p2.y, 5);
@@ -61,6 +60,12 @@ class Bounder {
}

void compile(boolean Execute) {

if (Execute) {
state = 0;
covers.add(new Cover(p1, p2, p4, p3));
}

PVector ptopmid = new PVector((p1.x + p2.x)/2, (p1.y + p2.y)/2);
PVector pbotmid = new PVector((p3.x + p4.x)/2, (p3.y + p4.y)/2);

@@ -99,11 +104,17 @@ class Bounder {
println(cmdright);
//execl("/bin/sh", "-c", "cd", (const char *)0);
//exec("/bin/sh -c cd " + folderURI + " && " + cmdleft);
//String[] runConvert = { "/bin/bash", "-c", "cd " + folderURI + " && mkdir " + folderName + " && " + cmdleft + " && " + cmdright + " && " + cmdpdf };
String[] runConvert = { "/bin/bash", "-c", "cd " + folderURI + " && mkdir " + folderName + " && " + cmdleft + " && " + cmdright };

if(Execute) exec(runConvert);

if (Execute) exec(runConvert);






//println(leftLeftTopX + "," + leftLeftTopY + " " + leftRightTopX + "," + leftRightTopY + " " + leftRightBotX + "," + leftRightBotY + " " + leftLeftBotX + "," + leftLeftBotY);
//println(rightLeftTopX + "," + rightLeftTopY + " " + rightRightTopX + "," + rightRightTopY + " " + rightRightBotX + "," + rightRightBotY + " " + rightLeftBotX + "," + rightLeftBotY);

+ 19
- 0
cover.pde View File

@@ -0,0 +1,19 @@
class Cover {
PVector p1, p2, p3, p4;
PShape coverRect;
Cover(PVector p1_, PVector p2_, PVector p3_, PVector p4_) {
p1 = new PVector(p1_.x, p1_.y);
p2 = new PVector(p2_.x, p2_.y);
p3 = new PVector(p3_.x, p3_.y);
p4 = new PVector(p4_.x, p4_.y);
coverRect = createShape();
coverRect.beginShape();
coverRect.fill(0,200);
coverRect.noStroke();
coverRect.vertex(p1.x, p1.y);
coverRect.vertex(p2.x, p2.y);
coverRect.vertex(p3.x, p3.y);
coverRect.vertex(p4.x, p4.y);
coverRect.endShape(CLOSE);
}
}

+ 9
- 2
scancropper2.pde View File

@@ -5,17 +5,19 @@ Bounder bounder;
int imageNo = 0;
int imageAmount;

ArrayList<Cover> covers = new ArrayList<Cover>();

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();
@@ -33,6 +35,11 @@ void draw() {
}
}

for (int i = 0; i < covers.size(); i++) {
Cover c = covers.get(i);
shape(c.coverRect);
}

bounder.update();
bounder.display();
}
@@ -102,7 +109,7 @@ void dropEvent(DropEvent theDropEvent) {
imagePaths = imgs.toArray(imagePaths);
imagePaths = sort(imagePaths);
images = new PImage[imageAmount];
if(imageNo++ <= imageAmount) imageNo++; //open on page 2
if (imageNo++ <= imageAmount) imageNo++; //open on page 2
setImage(imageNo);
surface.setSize(displayWidth, displayHeight);
}

Loading…
Cancel
Save