I have a code of a vibrating rectangle with a video captured by the webcam. As you play with the mouse, the aspect ratio changes. I was wondering how to do it so when there is motion or a change in position detected by the camera, the aspect ration changes
below is my code
float x, y; // X and Y coordinates of text
PImage img;
int direction = 1;
float signal;
float spacer = 23.2;
import processing.video.*;
Capture video;
void setup() {
fullScreen();
noFill();
background(#000000);
stroke(255);
frameRate(30);
noStroke();
x = width / 2;
y = height / 2;
video = new Capture(this, 320, 240);
video.start();
noCursor();
}
void captureEvent(Capture video) {
video.read();
}
void draw() {
fill(random(10));
rect(0, 0, width, height);
fill(#FFFFFF);
tint(mouseX, mouseY, random(1000));
translate(width/2, height/2);
if (x<0) {
x = 10;
}
if (y<0) {
y = 10;
}
if (x>width) {
x = width*2;
}
if (y>height) {
y = height*2;
}
imageMode(CENTER);
rotate(PI/20);
image(video, random(100), random(100), mouseX, mouseY);
}