While I’m studying the book ‘Learning processing’, written by Daniel Shiffman, there’s keep error on my code.
import processing.video.*;
Capture video;
float x;
float y;
void setup() {
size(352, 288);
background(255);
x = width/2;
y = width/2;
video = new Capture(this, width, height);
video.start();
}
void captureEvent(Capture video) {
video.read();
}
void draw() {
video.loadPixels();
float nex = constrain(x + random(-20, 20), 0, video.width-1);
float ney = constrain(y + random(-20, 20), 0, video.height-1);
int midx = int((x+nex)/2);
int midy = int((y+nex)/2);
println((video.width - midx - 1) + midy * video.width);
color c = video.pixels[(video.width - midx - 1) + midy * video.width];
stroke(c);
strokeWeight(6);
line(x, y, nex, ney);
x = nex;
y = ney;
}
it just keep telling me a limited array number and also the number keep changes.
could you help me?
you can check this code on the book that I mentioned chapter 16 video part.