//PHOTO BOOTH SLIDE SHOW

//import java.util.*;

//ArrayList photoStrip;
//ArrayList rightPhotoStrip;
Photo[] photoStrip = new Photo[30];
int numberOfPhotos = 1;
boolean fileExists = true;
long pmillis;
int imageChoice;
int STRIPHEIGHT = 320;
int shootCount = 0;
boolean processShoot = false;
boolean drawShoot = false;
int i = 1;
int p1 = 0;
int p2 = 1;
int p3 = 2;
int p4 = 6;
int p5 = 7;
int p6 = 8;
int leftX = 1;
int rightX = 719;
Photo firstPhoto;
Photo secondPhoto;
Photo thirdPhoto;
Photo forthPhoto;
Photo fifthPhoto;
Photo sixthPhoto;
PImage newPhoto;
PImage newPhoto2;
PImage newPhoto3;
String filename;
String filename2;
String filename3;

void setup(){

size(960, 640);
frameRate(20);
//photoStrip = new ArrayList(); // rightPhotoStrip = new ArrayList();

while (fileExists){
filename = "IMG_" + nf(i, 4) + ".JPG";
PImage newPhoto = loadImage(filename);
println (filename);
if (newPhoto != null){
photoStrip[(i-1) % 30] = new Photo(newPhoto, 0,(i-1)*STRIPHEIGHT);
println("added" + numberOfPhotos);
i++;
numberOfPhotos++;
}
else{

fileExists = false;
//numberOfPhotos--;
println(numberOfPhotos);
}
}
firstPhoto = photoStrip[p1];
firstPhoto.drawPhotoStrip(leftX, 0);

secondPhoto = photoStrip[p2];
secondPhoto.drawPhotoStrip(leftX,320);

thirdPhoto = photoStrip[p3];
thirdPhoto.drawPhotoStrip(leftX,640);

forthPhoto = photoStrip[p4];
forthPhoto.drawPhotoStrip(rightX, 0);

fifthPhoto = photoStrip[p5];
fifthPhoto.drawPhotoStrip(rightX,320);

sixthPhoto = photoStrip[p6];
sixthPhoto.drawPhotoStrip(rightX,640);
}

void draw() {

if (drawShoot == true) { // IF THREE NEW PHOTOS HAVE BEEN FOUND
background(0);
// delay(2000);
newPhoto = loadImage(filename);
newPhoto2 = loadImage(filename2);
newPhoto3 = loadImage(filename3);
image(newPhoto, 110, 100, 230, 315);
image(newPhoto2, 355, 100, 230, 315);
image(newPhoto3, 600, 100, 230, 315);
// delay(10000);
processShoot = true;
shootCount = 0;
if (millis() - pmillis >= 20000){ // WAIT FOR USER TO VIEW
drawShoot = false; // RESET
}
}
else {

background(40,40,30);

firstPhoto.drawPhotoStrip(leftX, firstPhoto.returnYPos() - 2);
secondPhoto.drawPhotoStrip(leftX, secondPhoto.returnYPos() - 2);
thirdPhoto.drawPhotoStrip(leftX, thirdPhoto.returnYPos() - 2);

forthPhoto.drawPhotoStrip(rightX, forthPhoto.returnYPos() - 2);
fifthPhoto.drawPhotoStrip(rightX, fifthPhoto.returnYPos() - 2);
sixthPhoto.drawPhotoStrip(rightX, sixthPhoto.returnYPos() - 2);

// LEFT STRIP

if (firstPhoto.returnYPos() < -320) {
p1 = (p1 + 3) % 30;
firstPhoto = photoStrip[p1];
firstPhoto.drawPhotoStrip(leftX, 640);
}
if (secondPhoto.returnYPos() < -320) {
p2 = (p2 + 3) % 30;
secondPhoto = photoStrip[p2];
secondPhoto.drawPhotoStrip(leftX, 640);
}
if (thirdPhoto.returnYPos() < -320) {
p3 = (p3 + 3) % 30;
thirdPhoto = photoStrip[p3];
thirdPhoto.drawPhotoStrip(leftX, 640);
}

// RIGHT STRIP

if (forthPhoto.returnYPos() < -320) {
p4 = (p4 + 3) % 30;
forthPhoto = photoStrip[p4];
forthPhoto.drawPhotoStrip(rightX, 640);
}
if (fifthPhoto.returnYPos() < -320) {
p5 = (p5 + 3) % 30;
fifthPhoto = photoStrip[p5];
fifthPhoto.drawPhotoStrip(rightX, 640);
}
if (sixthPhoto.returnYPos() < -320) {
p6 = (p6 + 3) % 30;
sixthPhoto = photoStrip[p6];
sixthPhoto.drawPhotoStrip(rightX, 640);
}

Photo centralPhoto = photoStrip[imageChoice];
centralPhoto.drawCentralImage();

if (millis() - pmillis >= 6000){

imageChoice = floor(random(29)); //DRAW CENTRAL IMAGE
// println(imageChoice);

if (processShoot == false){
filename = "IMG_" + nf(numberOfPhotos, 4) + ".JPG"; //NAME PHOTO 1
filename2 = "IMG_" + nf(numberOfPhotos+1, 4) + ".JPG"; //NAME PHOTO 2
filename3 = "IMG_" + nf(numberOfPhotos+2, 4) + ".JPG"; //NAME PHOTO 3
newPhoto = loadImage(filename); //CHECK FOR PHOTO 1
println(filename);
if (newPhoto != null && processShoot == false){ // numberOfPhotos++;
newPhoto2 = loadImage(filename2);
if (newPhoto2 != null){ // numberOfPhotos++;
newPhoto3 = loadImage(filename3);
if (newPhoto3 != null){ // numberOfPhotos++;
drawShoot = true;
}
}
}
}
if (processShoot == true) {
filename = "IMG_" + nf(numberOfPhotos, 4) + ".JPG"; //NAME PHOTO 1
PImage newPhoto = loadImage(filename); //CHECK FOR PHOTO 1
println("processing shoot...");
// Photo referencePhoto = (Photo)
//photoStrip.get(numberOfPhotos-1); // FIND THE LAST PHOTO IN THE ARRAY
Photo stripPhoto = new Photo(newPhoto, 0, 0);
photoStrip[numberOfPhotos % 30]= stripPhoto;
println("added new photo " + filename);
numberOfPhotos++;
shootCount ++;
}
pmillis = millis();
}
if (shootCount >= 3){
processShoot = false;
}
}

}

 

//Class for the photos to be stored in
class Photo{
PImage photo;
int xPos;
int yPos;
int xTemp;

Photo(PImage _photo, int _xPos, int _yPos){
photo = _photo;
xPos = _xPos;
yPos = _yPos;
}

void drawPhotoStrip(int _x, int _y ){
xPos = _x;
yPos = _y;

noStroke();
fill(255,255,240);
rect(xPos, yPos, 240, STRIPHEIGHT);
image(photo, xPos+5, yPos+5, 230, 315);
}

void movePhotoStrip(){
yPos = yPos - 2;

}

int returnYPos(){
return yPos;
}

void drawCentralImage(){
stroke(250,250,240);
strokeWeight(2);
noFill();
rect(260,10,width - 520, height - 20);
image(photo, 260,10,width - 520, height - 20); // old values: 250, 10, 500, 20
stroke(0);
strokeWeight(2);
fill(20);
triangle(245, 5, 305, 5, 245, 65);
triangle(245, height - 5, 305, height - 5, 245, height - 65);
triangle(width - 245, 5, width - 305, 5, width - 245, 65);
triangle(width - 245,height - 5, width - 305, height - 5, width -
245, height - 65);
}
}