Recitation 11: Workshops by Molly (Weiyi He)

Media Manipulation

int size= 3;
import processing.video.*;
Capture cam;
//PImage myImage;

void setup() {
size(600,600);
//myImg= loadImage(“76.2277_ph_web-1.jpg”);
cam=new Capture(this, 640, 480);
cam.start();
}

void draw() {
if (cam.available()){
cam.read();
}

background(0);
noStroke();
cam.loadPixels();
for (int x=0; x<cam.width; x=x+size) {
for (int y=0; y<cam.height; y=y+size) {
//colorMode(HSB, 100);
//fill(x*100/width, y*100/height, 100);

int index=(y*cam.width)+x;
fill(cam.pixels[index]);

float d= dist(x, y, mouseX, mouseY);
d= map(d, 0, sqrt(width*width+height*height), 1, size*10);

float angle=map(d, 1, size*2, 0, PI);
pushMatrix();
translate(x, y);
rotate(angle);
rect(0, 0, d, d);
popMatrix();
}
}
}

Leave a Reply