mirror mirrored from Colin Narver on Vimeo.
—————————————————————————————————-
Here is the code:
import processing.video.*;
// Size of each cell in the grid
int cellSize = 15;
// Number of columns and rows in our system
int cols, rows;
// Variable for capture device
Capture video;
void setup() {
size(1200,800, P2D);
//set up columns and rows
cols = width / cellSize;
rows = height / cellSize;
colorMode(RGB, 255, 255, 255, 255);
rectMode(CENTER);
video = new Capture(this, width, height);
video.start();
background(0);
}
void draw() {
if (video.available()) {
video.read();
video.loadPixels();
background(0);
// Tinting using mouse location
tint(width, height, 0, random(200,255));
image(video,0,0,width,height);
// Begin loop for columns
for (int i = 0; i < cols;i++) {
// Begin loop for rows
for (int j = 0; j < rows;j++) {
int x = i * cellSize;
int y = j * cellSize;
int loc = (video.width – x – 1) + y*video.width; // Reversing x to mirror the image
color c = video.pixels[loc];
float sz = (brightness(c) / 255.0) * cellSize*2;
fill(100, 50,100, 200);
noStroke();
ellipse(x+1 + cellSize/4, y+1 + cellSize/4, sz, sz);
}
}
}
}