From 0b9590e291884a792f67935d91ef7fbd3e00b780 Mon Sep 17 00:00:00 2001 From: timrolls Date: Tue, 5 Sep 2017 11:15:23 -0700 Subject: [PATCH 1/7] change blank points to 0,0 --- LightWork_Scraper/Scraper.pde | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/LightWork_Scraper/Scraper.pde b/LightWork_Scraper/Scraper.pde index 28de647..c5173e2 100644 --- a/LightWork_Scraper/Scraper.pde +++ b/LightWork_Scraper/Scraper.pde @@ -22,12 +22,12 @@ public class Scraper { // Now we can actually get the vertices from each child for (int j = 0; j < total; j++) { //using 1 to fix duplicate first point issue temporarily PVector v = child.getVertex(j); - if(v.x>=0 && v.y>=0){ + v.set (v.x, v.y); loc.add(v); //print(v); } - } + } } @@ -40,10 +40,12 @@ public class Scraper { int index=0; for (PVector temp : loc) { + if(temp.x>0 && temp.y>0){ temp.set (map(temp.x, norm[0], norm[2], 0, 1), map(temp.y, norm[1], norm[3], 0, 1)); loc.set(index, temp); index++; } + } } //show points in output window From f5cbccf8f491597ce73f7e815fce455af744b672 Mon Sep 17 00:00:00 2001 From: timrolls Date: Tue, 5 Sep 2017 11:26:28 -0700 Subject: [PATCH 2/7] more ignoring 0,0 points --- LightWork_Scraper/Scraper.pde | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/LightWork_Scraper/Scraper.pde b/LightWork_Scraper/Scraper.pde index c5173e2..e5f2862 100644 --- a/LightWork_Scraper/Scraper.pde +++ b/LightWork_Scraper/Scraper.pde @@ -66,8 +66,10 @@ public class Scraper { void update() { int index =0; for (PVector temp : loc) { + if(temp.x>0 && temp.y>0){ //ignore skipped points opc.led(index, (int)map(temp.x, 0, 1, margin, width-margin), (int)map(temp.y, 0, 1, margin, height-margin)); index++; + } } } @@ -82,9 +84,11 @@ public class Scraper { int index =0; for (PVector temp : loc) { + if(temp.x>0 && temp.y>0){ //ignore skipped points xArr[index] = temp.x; yArr[index] = temp.y; index++; + } } float minX = min(xArr); From c9a2b0c7c3e0e101f9b6759fcc965449160e8533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3=20Stef=C3=A1nsson?= Date: Tue, 5 Sep 2017 11:55:59 -0700 Subject: [PATCH 3/7] added complete layour file --- LightWork_Scraper/LightWork_Scraper.pde | 6 +++--- LightWork_Scraper/data/lightwork_map_complete.svg | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 LightWork_Scraper/data/lightwork_map_complete.svg diff --git a/LightWork_Scraper/LightWork_Scraper.pde b/LightWork_Scraper/LightWork_Scraper.pde index 429105a..113b697 100644 --- a/LightWork_Scraper/LightWork_Scraper.pde +++ b/LightWork_Scraper/LightWork_Scraper.pde @@ -13,7 +13,7 @@ void setup() { background(0); //initialize scraper - scrape = new Scraper("mapper-lightwork-filtered-negative.svg"); + scrape = new Scraper("lightwork_map_complete.svg"); scrape.init(); scrape.normCoords(); @@ -37,7 +37,7 @@ void draw() { fill(0,0,255); if(pos<=width)pos+=5; else pos=0; - rect(pos,0,100,height); - + //rect(pos,0,100,height); + ellipse(mouseX, mouseY, 30, 30); } \ No newline at end of file diff --git a/LightWork_Scraper/data/lightwork_map_complete.svg b/LightWork_Scraper/data/lightwork_map_complete.svg new file mode 100644 index 0000000..a2b1053 --- /dev/null +++ b/LightWork_Scraper/data/lightwork_map_complete.svg @@ -0,0 +1,3 @@ + + + From 7466878949c8326326b2d33cd171a29a90038ce3 Mon Sep 17 00:00:00 2001 From: timrolls Date: Tue, 5 Sep 2017 13:08:28 -0700 Subject: [PATCH 4/7] Fixed index and overwriting 0 error --- LightWork_Scraper/LightWork_Scraper.pde | 6 ++-- LightWork_Scraper/Scraper.pde | 44 ++++++++++++++----------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/LightWork_Scraper/LightWork_Scraper.pde b/LightWork_Scraper/LightWork_Scraper.pde index 113b697..da924ca 100644 --- a/LightWork_Scraper/LightWork_Scraper.pde +++ b/LightWork_Scraper/LightWork_Scraper.pde @@ -28,7 +28,7 @@ void setup() { void draw() { background(0); - rect(0,0,50,50); + //rect(0,0,50,50); //scrape.update(); scrape.display(); @@ -37,7 +37,7 @@ void draw() { fill(0,0,255); if(pos<=width)pos+=5; else pos=0; - //rect(pos,0,100,height); - ellipse(mouseX, mouseY, 30, 30); + rect(pos,0,100,height); + //ellipse(mouseX, mouseY, 30, 30); } \ No newline at end of file diff --git a/LightWork_Scraper/Scraper.pde b/LightWork_Scraper/Scraper.pde index e5f2862..bd693f0 100644 --- a/LightWork_Scraper/Scraper.pde +++ b/LightWork_Scraper/Scraper.pde @@ -22,12 +22,11 @@ public class Scraper { // Now we can actually get the vertices from each child for (int j = 0; j < total; j++) { //using 1 to fix duplicate first point issue temporarily PVector v = child.getVertex(j); - + v.set (v.x, v.y); loc.add(v); //print(v); - } - + } } } @@ -35,17 +34,19 @@ public class Scraper { void normCoords() { float[] norm = new float[4]; - norm = getMinMaxCoords(); + norm = getMinMaxCoords(loc); int index=0; + //println(loc); + for (PVector temp : loc) { - if(temp.x>0 && temp.y>0){ - temp.set (map(temp.x, norm[0], norm[2], 0, 1), map(temp.y, norm[1], norm[3], 0, 1)); - loc.set(index, temp); + if (temp.x>0 && temp.y>0) { + temp.set (map(temp.x, norm[0], norm[2], 0, 1), map(temp.y, norm[1], norm[3], 0, 1)); + loc.set(index, temp); + } index++; } - } } //show points in output window @@ -57,20 +58,23 @@ public class Scraper { //draw based on coords in arraylist. enhanced arraylist loop for (PVector temp : loc) { - ellipse(map(temp.x, 0, 1, margin, width-margin), map(temp.y, 0, 1, margin, height-margin), 10, 10); + if (temp.x>0 && temp.y>0) { + ellipse(map(temp.x, 0, 1, margin, width-margin), map(temp.y, 0, 1, margin, height-margin), 10, 10); + } } - } //set led coords in opc client void update() { int index =0; for (PVector temp : loc) { - if(temp.x>0 && temp.y>0){ //ignore skipped points + //if(temp.x>0 && temp.y>0){ //ignore skipped points opc.led(index, (int)map(temp.x, 0, 1, margin, width-margin), (int)map(temp.y, 0, 1, margin, height-margin)); index++; - } + //} } + + println(loc.size()); } ArrayList getArray() { @@ -78,16 +82,16 @@ public class Scraper { } //deterimines bounding box of points in SVG for normalizing - float[] getMinMaxCoords() { - float xArr[] = new float[loc.size()]; - float yArr[] = new float[loc.size()]; + float[] getMinMaxCoords(ArrayList points) { + float xArr[] = new float[points.size()]; + float yArr[] = new float[points.size()]; int index =0; - for (PVector temp : loc) { - if(temp.x>0 && temp.y>0){ //ignore skipped points - xArr[index] = temp.x; - yArr[index] = temp.y; - index++; + for (PVector temp : points) { + if (temp.x>0 && temp.y>0) { //ignore skipped points + xArr[index] = temp.x; + yArr[index] = temp.y; + index++; } } From 467d0db46f3cf3cfad483ad5ea875166488ac0d5 Mon Sep 17 00:00:00 2001 From: timrolls Date: Tue, 5 Sep 2017 13:46:37 -0700 Subject: [PATCH 5/7] fixed normalization of points --- LightWork_Scraper/LightWork_Scraper.pde | 18 ++++++++--------- LightWork_Scraper/Scraper.pde | 27 ++++++++++++++++--------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/LightWork_Scraper/LightWork_Scraper.pde b/LightWork_Scraper/LightWork_Scraper.pde index da924ca..381167c 100644 --- a/LightWork_Scraper/LightWork_Scraper.pde +++ b/LightWork_Scraper/LightWork_Scraper.pde @@ -11,7 +11,7 @@ float margin =50; void setup() { size(800, 800, JAVA2D); //wtf background(0); - + //initialize scraper scrape = new Scraper("lightwork_map_complete.svg"); scrape.init(); @@ -20,24 +20,22 @@ void setup() { opc = new OPC(this, "fade1.local", 7890); scrape.update(); opc.showLocations(false); - + //display array of points from SVG //println(scrape.getArray()); } void draw() { background(0); - - //rect(0,0,50,50); - //scrape.update(); + + //rect(0,0,50,50); //test margin bounds scrape.display(); - + //simple chase animation noStroke(); - fill(0,0,255); - if(pos<=width)pos+=5; + fill(0, 0, 255); + if (pos<=width)pos+=5; else pos=0; - rect(pos,0,100,height); + rect(pos, 0, 100, height); //ellipse(mouseX, mouseY, 30, 30); - } \ No newline at end of file diff --git a/LightWork_Scraper/Scraper.pde b/LightWork_Scraper/Scraper.pde index bd693f0..a809c04 100644 --- a/LightWork_Scraper/Scraper.pde +++ b/LightWork_Scraper/Scraper.pde @@ -68,10 +68,8 @@ public class Scraper { void update() { int index =0; for (PVector temp : loc) { - //if(temp.x>0 && temp.y>0){ //ignore skipped points opc.led(index, (int)map(temp.x, 0, 1, margin, width-margin), (int)map(temp.y, 0, 1, margin, height-margin)); index++; - //} } println(loc.size()); @@ -83,18 +81,27 @@ public class Scraper { //deterimines bounding box of points in SVG for normalizing float[] getMinMaxCoords(ArrayList points) { - float xArr[] = new float[points.size()]; - float yArr[] = new float[points.size()]; + ArrayList pointsCopy = new ArrayList(points); - int index =0; - for (PVector temp : points) { - if (temp.x>0 && temp.y>0) { //ignore skipped points - xArr[index] = temp.x; - yArr[index] = temp.y; - index++; + for (int i=pointsCopy.size()-1; i>=0; i--) { + PVector temp = pointsCopy.get(i); + if (temp.x==0 && temp.y==0) { + pointsCopy.remove(i); } } + float xArr[] = new float[pointsCopy.size()]; + float yArr[] = new float[pointsCopy.size()]; + + int index =0; + for (PVector temp : pointsCopy) { + + xArr[index] = temp.x; + yArr[index] = temp.y; + + index++; + } + float minX = min(xArr); float minY = min(yArr); float maxX = max(xArr); From 6f0dfa380ccb97836b5dbc3e65295475caa8e03a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3=20Stef=C3=A1nsson?= Date: Thu, 7 Sep 2017 15:45:44 -0700 Subject: [PATCH 6/7] fixed invisible LEDs (floating point error) --- LightWork_Scraper/LightWork_Scraper.pde | 20 ++++++++++++++++---- LightWork_Scraper/Scraper.pde | 10 +++++++--- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/LightWork_Scraper/LightWork_Scraper.pde b/LightWork_Scraper/LightWork_Scraper.pde index 381167c..001643a 100644 --- a/LightWork_Scraper/LightWork_Scraper.pde +++ b/LightWork_Scraper/LightWork_Scraper.pde @@ -13,7 +13,7 @@ void setup() { background(0); //initialize scraper - scrape = new Scraper("lightwork_map_complete.svg"); + scrape = new Scraper("mapper-lightwork_filteringTesting.svg"); scrape.init(); scrape.normCoords(); @@ -27,7 +27,17 @@ void setup() { void draw() { background(0); - + + // Test animation + //noFill(); + //strokeWeight(25); + //for (int i = 0; i < 100; i+=10) { + // stroke(255-i*2.5, i*2.5, 255*sin(frameCount*0.02)); + // ellipse(width/2, height/2, i*100*sin(frameCount*0.02), i*100*sin(frameCount*0.02)); + //} + // End test animation + + //rect(0,0,50,50); //test margin bounds scrape.display(); @@ -36,6 +46,8 @@ void draw() { fill(0, 0, 255); if (pos<=width)pos+=5; else pos=0; - rect(pos, 0, 100, height); - //ellipse(mouseX, mouseY, 30, 30); + //rect(pos, 0, 100, height); + ellipse(mouseX, mouseY, 30, 30); + + } \ No newline at end of file diff --git a/LightWork_Scraper/Scraper.pde b/LightWork_Scraper/Scraper.pde index a809c04..ba4b15e 100644 --- a/LightWork_Scraper/Scraper.pde +++ b/LightWork_Scraper/Scraper.pde @@ -58,11 +58,15 @@ public class Scraper { //draw based on coords in arraylist. enhanced arraylist loop for (PVector temp : loc) { - if (temp.x>0 && temp.y>0) { - ellipse(map(temp.x, 0, 1, margin, width-margin), map(temp.y, 0, 1, margin, height-margin), 10, 10); + if (temp.x==0.0 && temp.y==0.0) { + stroke(0,0,0); + } + else { + stroke(255, 255, 255); } + ellipse(map(temp.x, 0, 1, margin, width-margin), map(temp.y, 0, 1, margin, height-margin), 10, 10); } - } + } //<>// //set led coords in opc client void update() { From e49ff914321a104fbe4dcd165d676e34520e15a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3=20Stef=C3=A1nsson?= Date: Fri, 8 Sep 2017 14:58:45 -0700 Subject: [PATCH 7/7] window size and animation tweaks. --- LightWork_Scraper/LightWork_Scraper.pde | 10 +++++----- LightWork_Scraper/Scraper.pde | 17 +++++++---------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/LightWork_Scraper/LightWork_Scraper.pde b/LightWork_Scraper/LightWork_Scraper.pde index 001643a..aa4ed93 100644 --- a/LightWork_Scraper/LightWork_Scraper.pde +++ b/LightWork_Scraper/LightWork_Scraper.pde @@ -9,11 +9,11 @@ int pos; float margin =50; void setup() { - size(800, 800, JAVA2D); //wtf + size(640, 480, JAVA2D); //wtf background(0); //initialize scraper - scrape = new Scraper("mapper-lightwork_filteringTesting.svg"); + scrape = new Scraper("layout.svg"); scrape.init(); scrape.normCoords(); @@ -32,7 +32,7 @@ void draw() { //noFill(); //strokeWeight(25); //for (int i = 0; i < 100; i+=10) { - // stroke(255-i*2.5, i*2.5, 255*sin(frameCount*0.02)); + // stroke(255-i*2.5*sin(frameCount*0.7), i*2.5*sin(frameCount*0.5), 255*sin(frameCount*0.2)); // ellipse(width/2, height/2, i*100*sin(frameCount*0.02), i*100*sin(frameCount*0.02)); //} // End test animation @@ -43,10 +43,10 @@ void draw() { //simple chase animation noStroke(); - fill(0, 0, 255); + fill(255*sin(frameCount*0.1), 255*sin(frameCount*0.3), 255*cos(frameCount*0.6)); if (pos<=width)pos+=5; else pos=0; - //rect(pos, 0, 100, height); + rect(pos, 0, 100, height); ellipse(mouseX, mouseY, 30, 30); diff --git a/LightWork_Scraper/Scraper.pde b/LightWork_Scraper/Scraper.pde index ba4b15e..c98c0b5 100644 --- a/LightWork_Scraper/Scraper.pde +++ b/LightWork_Scraper/Scraper.pde @@ -42,8 +42,9 @@ public class Scraper { for (PVector temp : loc) { if (temp.x>0 && temp.y>0) { - temp.set (map(temp.x, norm[0], norm[2], 0, 1), map(temp.y, norm[1], norm[3], 0, 1)); + temp.set (map(temp.x, norm[0], norm[2], 0.001, 1), map(temp.y, norm[1], norm[3], 0.001, 1)); loc.set(index, temp); + } index++; } @@ -58,18 +59,14 @@ public class Scraper { //draw based on coords in arraylist. enhanced arraylist loop for (PVector temp : loc) { - if (temp.x==0.0 && temp.y==0.0) { - stroke(0,0,0); - } - else { - stroke(255, 255, 255); - } - ellipse(map(temp.x, 0, 1, margin, width-margin), map(temp.y, 0, 1, margin, height-margin), 10, 10); + if (!(temp.x == 0.0) && !(temp.y == 0.0)) { + ellipse(map(temp.x, 0, 1, margin, width-margin), map(temp.y, 0, 1, margin, height-margin), 10, 10); + } } - } //<>// + } //set led coords in opc client - void update() { + void update() { //<>// int index =0; for (PVector temp : loc) { opc.led(index, (int)map(temp.x, 0, 1, margin, width-margin), (int)map(temp.y, 0, 1, margin, height-margin));