diff --git a/LightWork_Scraper/LightWork_Scraper.pde b/LightWork_Scraper/LightWork_Scraper.pde index 429105a..aa4ed93 100644 --- a/LightWork_Scraper/LightWork_Scraper.pde +++ b/LightWork_Scraper/LightWork_Scraper.pde @@ -9,18 +9,18 @@ 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-filtered-negative.svg"); + scrape = new Scraper("layout.svg"); scrape.init(); scrape.normCoords(); opc = new OPC(this, "fade1.local", 7890); scrape.update(); opc.showLocations(false); - + //display array of points from SVG //println(scrape.getArray()); } @@ -28,16 +28,26 @@ void setup() { void draw() { background(0); - rect(0,0,50,50); - //scrape.update(); - scrape.display(); + // Test animation + //noFill(); + //strokeWeight(25); + //for (int i = 0; i < 100; i+=10) { + // 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 + + //rect(0,0,50,50); //test margin bounds + scrape.display(); + //simple chase animation noStroke(); - fill(0,0,255); - if(pos<=width)pos+=5; + 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); + } \ No newline at end of file diff --git a/LightWork_Scraper/Scraper.pde b/LightWork_Scraper/Scraper.pde index 28de647..c98c0b5 100644 --- a/LightWork_Scraper/Scraper.pde +++ b/LightWork_Scraper/Scraper.pde @@ -22,11 +22,10 @@ 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); - } } } } @@ -35,13 +34,18 @@ public class Scraper { void normCoords() { float[] norm = new float[4]; - norm = getMinMaxCoords(); + norm = getMinMaxCoords(loc); int index=0; + //println(loc); + for (PVector temp : loc) { - 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.001, 1), map(temp.y, norm[1], norm[3], 0.001, 1)); + loc.set(index, temp); + + } index++; } } @@ -55,18 +59,21 @@ 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.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)); index++; } + + println(loc.size()); } ArrayList getArray() { @@ -74,14 +81,25 @@ 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) { + ArrayList pointsCopy = new ArrayList(points); + + 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 : loc) { + for (PVector temp : pointsCopy) { + xArr[index] = temp.x; yArr[index] = temp.y; + index++; } 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 @@ + + +