torifoster
YaBB Newbies
Offline
Posts: 6
multiple arrays causes data to drop
Nov 9th , 2008, 11:55pm
I created a sketch that works properly with one array. When I add two more arrays to the sketch it thinks the length of one array applies to all the arrays. For example, if I want three different arrays of 60 images each to draw sequentially, it will draw only 20 images per array (totaling 60 instead of the desired 180). Does anyone know what I'm doing incorrectly? Here is the code: // This sketch draws stills from three different video streams. import processing.video.*; int xpos; int ypos; int xWidth; int yHeight; int count = 0; int numImagesB = 48; int numImagesM = 48; int numImagesT = 48; PImage[] imagesB = new PImage[numImagesB]; // Declairs the bottom images PImage[] imagesM = new PImage[numImagesM]; // Declairs the middle images PImage[] imagesT = new PImage[numImagesT]; // Declairs the top images PImage maskImg; MovieMaker mm; // Declare MovieMaker object void setup() { size(1020, 840); background(0); frameRate(6); xpos = width - 300; ypos = 0; mm = new MovieMaker(this, width, height, "drawing.mov", 6, MovieMaker.H263, MovieMaker.LOSSLESS); // I don't think that this does what I thought it does, and I don't think I need it. /* // This loop draws the mask over each image in all image arrays. for (int i = 1; i <= imagesB.length; i++) { imagesB[i-1] = loadImage("B (" + i + ").jpg"); } */ maskImg = loadImage("aMask3.jpg"); // This loop prepairs each image in the bottom image array. for (int i = 1; i <= imagesB.length; i++) { imagesB[i-1] = loadImage("B (" + i + ").jpg"); imagesB[i-1].mask(maskImg); } // This loop prepairs each image in the middle image array. for (int j = 1; j <= imagesM.length; j++) { imagesM[j-1] = loadImage("M (" + j + ").jpg"); imagesM[j-1].mask(maskImg); } // This loop prepairs each image in the top image array. for (int k = 1; k <= imagesT.length; k++) { imagesT[k-1] = loadImage("T (" + k + ").jpg"); imagesT[k-1].mask(maskImg); } } void draw() { // Drawing the bottom image array if (count < imagesB.length) { tint(225, 225, 225, createTint()); image(imagesB[count], xpos, ypos + 600); count++; mm.addFrame(); // Add window's pixels to movie } for (int f = distanceBtwnImages(); f <= distanceBtwnImages(); f++) { xpos = xpos - f; } // Drawing the middle image array if (count < imagesM.length) { tint(225, 225, 225, createTint()); image(imagesM[count], xpos, ypos + 300); count++; } for (int g = distanceBtwnImages(); g <= distanceBtwnImages(); g++) { xpos = xpos - g; } // Drawing the top image array if (count < imagesT.length) { tint(225, 225, 225, createTint()); image(imagesT[count], xpos, ypos); count++; } for (int h = distanceBtwnImages(); h <= distanceBtwnImages(); h++) { xpos = xpos - h; } } int distanceBtwnImages(){ int numberIs; numberIs = 9; return numberIs; } int createTint(){ int numberIs; numberIs = 160; return numberIs; } // This is the method that stops the recording of the movie void keyPressed() { if (key == ' ') { mm.finish(); // Finish the movie if space bar is pressed! } }