I have the follow script that creates a 'pond effect'. The background is a live capture aimed at the users head to simulate a reflection. Where I am stuck is that I need dual cameras working to also use a home made multitouch display.
Script:
Capture img;
Ripple ripple;
void setup() {
img = new Capture(this, 680, 420);
size(680, 420);
ripple = new Ripple();
frameRate(60);
}
void draw() {
if (img.available() == true) {
img.read();
image(img, 160, 100);
// The following does the same, and is faster when just drawing the image
// without any additional resizing, transformations, or tint.
//set(160, 100, cam);
loadPixels();
img.loadPixels();
for (int loc = 0; loc < width * height; loc++) {
pixels[loc] = ripple.col[loc];
}
updatePixels();
ripple.newframe();
}
}
class Ripple {
int i, a, b;
int oldind, newind, mapind;
short ripplemap[]; // the height map
int col[]; // the actual pixels
int riprad;
int rwidth, rheight;
int ttexture[];
int ssize;
I have managed to combine two sources to make a colourful ripple effect with a continuous flow but I am now stuck as to how I make the background transparent.
This is to be projected on to a wall, hence the desire for it to be see through. Here is the source code for what I already have....
//ring.pde
ArrayList ripples;
color bg = 0;
int c1 = 255; // Color array
int c2 = 127;
color[] c = {
color(c1, c2, 0), color(c1, 0, c2), color(c2, c1, 0), color(c2, 0, c1), color(0, c2, c1), };
void draw() {
background(bg);
for( int i = ripples.size()-1; i >= 0;i--){
Ripple ripple = (Ripple) ripples.get(i);
ripple.resize();
ripple.display();
if(!ripple.on)ripples.remove(i);
}
}
void mouseDragged() {
int which = round(random(4)); // pick a color, any color (or the number associateing to that color in the array)
ripples.add(new Ripple(mouseX, mouseY, which));
}