import processing.video.*;
Capture video;
int x = 0;
void setup() {
size(2000, 720);
frameRate(120);
video = new Capture(this, 1280, 720);
// Start capturing the images from the camera
video.start();
background(0);
}
void captureEvent(Capture video) {
video.read();
}
void draw() {
int w = video.width;
int h = video.height;
copy(video, w/2, 0, 1, h, x, 0, 1, h);
x = x + 1;
//panning
if (x > width) {
x = 0;
//panning cycles back to beginning
}
}
but i need start the capture from the center of screen, it will be like the circle or the clock (rotate it ) like this :
cool sketch! here’s how you can make the circular effect work:
import processing.video.*;
Capture video;
//changed to float
float x = 0;
void setup() {
size(960, 960);
frameRate(120);
video = new Capture(this, 640, 480);
// Start capturing the images from the camera
video.start();
background(0);
}
void captureEvent(Capture video) {
video.read();
}
void draw() {
int w = video.width;
int h = video.height;
x += 1; //you can change this to e.g. 0.5 to make it less choppy
//panning
//new center in the middle of the sketch
translate(width / 2, height / 2);
//use x to rotate around the new center
float rotation = map(x, 0, width, 0, TWO_PI);
rotate(rotation);
//copy always to the same place, while the canvas is being rotated
//copied slits are a bit bigger now to avoid black stripes inbetween (and moiree)
copy(video, w/2, 0, 10, h, 0, -height/2, 10, h);
if (x > width) {
x = 0;
//panning cycles back to beginning
}
}