From 9e990c12edca8a9787ccfb3b6e63dbd6080c8a24 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Fri, 8 Jan 2021 22:42:17 +0100 Subject: [PATCH] added class to cover parts of image that were already cropped --- bounder.pde | 21 ++++++++++++++++----- cover.pde | 19 +++++++++++++++++++ scancropper2.pde | 11 +++++++++-- 3 files changed, 44 insertions(+), 7 deletions(-) create mode 100644 cover.pde diff --git a/bounder.pde b/bounder.pde index 1ef7d19..b7f360a 100644 --- a/bounder.pde +++ b/bounder.pde @@ -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); diff --git a/cover.pde b/cover.pde new file mode 100644 index 0000000..66fcd63 --- /dev/null +++ b/cover.pde @@ -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); + } +} diff --git a/scancropper2.pde b/scancropper2.pde index 48dafb7..b8232e4 100644 --- a/scancropper2.pde +++ b/scancropper2.pde @@ -5,17 +5,19 @@ 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(); @@ -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); }