Created
March 5, 2012 00:27
Revisions
-
neufuture revised this gist
Mar 5, 2012 . 1 changed file with 103 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,27 +1,119 @@ import processing.video.*; Capture feed; BlurBox bb[] = new BlurBox[5]; void setup() { size(320, 240); feed = new Capture(this, 320, 240, Capture.list()[0]); feed.start(); for (int i=0; i<bb.length; i++) { // create multiple BlurBox objects at random locations bb[i] = new BlurBox((int)random(width), (int)random(height), 40, 40); } } void draw() { if (feed.available() == true) { feed.read(); } image(feed, 0, 0, width, height); for (int i=0; i<bb.length; i++) { bb[i].display(); } } void mousePressed() { for (int i=0; i<bb.length; i++) { //if one box is clicked, stop checking if (bb[i].clicked(mouseX, mouseY)) break; } } void mouseReleased() { for (int i=0; i<bb.length; i++) { bb[i].stopDragging(); } } void mouseDragged() { for (int i=0; i<bb.length; i++) { if (bb[i].dragging) bb[i].drag(mouseX, mouseY); } } class BlurBox { int x, y, w, h; boolean dragging = false; // Is the object being dragged? int offsetX, offsetY; // Mouseclick offset PImage blurred; BlurBox (int x_, int y_, int w_, int h_) { x = x_; y = y_; w = w_; h = h_; offsetX = 0; offsetY = 0; blurred = new PImage(w_, h_); } void display() { // pushMatrix(); you shouldn't need this if (dragging) stroke(255, 255, 0); else noStroke(); //fill(0, 0, 0, 150); noFill(); //filter(BLUR, 6); blurred = get(x, y, w, h); blurred.filter(BLUR, 5); image(blurred, x, y); rect(x, y, w, h); // popMatrix(); you shouldn't need this either } // Is a point inside the rectangle (for click)? boolean clicked(int mx, int my) { if (mx > x && mx < x + w && my > y && my < y + h) { dragging = true; // If so, keep track of relative location of click to corner of rectangle offsetX = x-mx; offsetY = y-my; return true; } else return false; } // Is a point inside the rectangle (for rollover) /*void rollover(int mx, int my) { if (mx > x && mx < x + w && my > y && my < y + h) { rollover = true; } else { rollover = false; } }*/ // Stop dragging void stopDragging() { dragging = false; } // Drag the rectangle void drag(int mx, int my) { if (dragging) { x = mx + offsetX; y = my + offsetY; } } } -
neufuture renamed this gist
Mar 5, 2012 . 1 changed file with 12 additions and 12 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,27 +1,27 @@ import processing.video.*; Capture feed; PImage blurred; int blurAmount = 5; int blurSize = 40; void setup() { size(320, 240); feed = new Capture(this, 320, 240, Capture.list()[0]); feed.start(); blurred = new PImage(blurSize, blurSize); noCursor(); imageMode(CENTER); } void draw() { if (feed.available() == true) { feed.read(); } image(feed, width/2, height/2, width, height); blurred = get(mouseX-blurSize/2, mouseY-blurSize/2, blurSize, blurSize); blurred.filter(BLUR, blurAmount); image(blurred, mouseX, mouseY); } -
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ import processing.video.*; PImage blurred; Movie movie; int blurSize = 40; void setup() { size(200, 200); movie = new Movie(this, "station.mov"); movie.loop(); blurred = new PImage(blurSize, blurSize); noCursor(); imageMode(CENTER); } void movieEvent(Movie movie) { movie.read(); } void draw() { image(movie, width/2, height/2, width, height); blurred = get(mouseX-blurSize/2, mouseY-blurSize/2, blurSize, blurSize); blurred.filter(BLUR, 5); image(blurred, mouseX, mouseY); }