Slit-Scan modified

We changed this so it will save at the end of every scan and restart again.

/**
* Simple Real-Time Slit-Scan Program.
* By Golan Levin.
*
* This demonstration depends on the canvas height being equal
* to the video capture height. If you would prefer otherwise,
* consider using the image copy() function rather than the
* direct pixel-accessing approach I have used here.
*
* Created December 2006.
* Updated September 2011 by James Hale.
*/
import processing.video.*;

Capture video;

int videoSliceX;
int drawPositionX;

void setup() {
size(1000, 480, P2D);

// Uses the default video input, see the reference if this causes an error
video = new Capture(this, 1000, 480, 60);

videoSliceX = video.width / 2;
drawPositionX = width - 1;
background(0);
}

void draw() {
if (video.available()) {
video.read();
video.loadPixels();

// Copy a column of pixels from the middle of the video
// To a location moving slowly across the canvas.
loadPixels();
for (int y = 0; y < video.height; y++){
int setPixelIndex = y*width + drawPositionX;
int getPixelIndex = y*video.width + videoSliceX;
pixels[setPixelIndex] = video.pixels[getPixelIndex];
}
updatePixels();

drawPositionX--;

// Saves your image if pixels reach the end of the frame
if (drawPositionX < 0) {
saveFrame();
drawPositionX = width - 1; // not sure this works
}
// Takes another photo if you click the mouse.
if(mousePressed) {
drawPositionX = width - 1;}
}
}