dieser sketch ist heute mit der hilfe von mario entstanden:
was ein spass! danke mario!
source:
import processing.video.*;
import processing.opengl.*;
float rY;
float rZ;
float rX;
// Size of each cell in the grid
int cellSize = 5;
// Number of columns and rows in our system
int cols, rows;
// Variable for capture device
Capture video;
void setup() {
size(640, 480, OPENGL);
frameRate(30);
cols = width / cellSize;
rows = height / cellSize;
colorMode(RGB, 255, 255, 255, 100);
// Uses the default video input, see the reference if this causes an error
video = new Capture(this, width, height, 12);
background(0);
}
void draw() {
if (video.available()) {
video.read();
video.loadPixels();
// Not bothering to clear background
background(0);
// translate(width/2,height/2,rX);
rotateY(radians(rY));
rotateX(radians(rZ));
// 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;
float r = red(video.pixels[loc]);
float g = green(video.pixels[loc]);
float b = blue(video.pixels[loc]);
// a new color with an alpha component
color c = color(r, g, b);
//drawing a rect
pushMatrix();
translate(x+cellSize/2, y+cellSize/2,brightness(c)-200);
fill(c);
noStroke();
// try this instead of rect
// box (cellSize);
rect(0, 0,cellSize, cellSize);
popMatrix();
}
}
}
}
void keyPressed() {
if ( key ==’+') {
rX += 5;
}else if ( key ==’-') {
rX -= 5;
}
if (key == CODED) {
if ( keyCode ==LEFT) {
rY+=3;
}else if ( keyCode ==RIGHT) {
rY-=3;
}else if ( keyCode ==UP) {
rZ+=3;
}else if ( keyCode ==DOWN) {
rZ-=3;
}
}
}