Another slight variation on the image read experiment. This time, the variation is based on the mouse distance, both for images and the webcam.
For images.
For Webcam
import processing.video.*;
float r = 5;
int xPix, yPix;
Capture video;
void setup (){
size (640,480, JAVA2D);
background (255);
smooth ();
noStroke ();
video = new Capture (this,width,height);
}
void draw (){
if (video.available()){
video.read();
}
for (int x = 0; x < 640; x+=20){
for (int y = 0; y < 480; y += 20){
float myDist = (dist (x, y, mouseX, mouseY)/12);
color c = video.get (x,y);
fill (c);
rectMode (CENTER);
rect (x,y,myDist,myDist);
}
}
}
For Images
PImage img;
void setup (){
img = loadImage ("picture1.jpg");
size (img.width,img.height);
noStroke ();
smooth ();
}
void draw (){
background (255);
for (int x = 0; x < img.width; x+=20){
for (int y = 0; y < img.height; y += 20){
float myDist = (dist (x, y, mouseX, mouseY)/8);
color c = img.get (x,y);
fill (c);
ellipseMode (CENTER);
ellipse (x,y, myDist,myDist);
}
}
}
Tags: drawing, processing, video