I can't for the life of me figure out how to call something between tabs. I tried to make this random image generator its own class but don't know how to call on it on the main program.
It seems from the example I have from the shiffman book is I need to do a .display() but it can't find the void portion in my class that I want to display. does this make sense?
here is my main program:
Images[] images = new Images[6];
import processing.pdf.*;
int i = 0;
int imageIndex = 0;
void setup() {
size(800,800);
imageMode(CENTER);
background(255);
fill (0);
text("click to restart", 205, 775, 300, 60);
text("click to save a PDF", 515, 775, 300, 60);
beginRecord(PDF, "artwork" + i +".pdf" );
}
void draw() {
//initialize images tab
display.display();
//crate restart
if (mouseX < 400 && mouseY > 750 && mousePressed){
fill(255);
rect(0, 0,800, 800);
fill(0);
text("click to restart", 205, 775, 300, 60);
text("click to save a PDF", 515, 775, 300, 60);
}
//create pdf
if (mouseX >400 && mouseY > 750 && mousePressed){
i = i++;
endRecord();
println("your art work awaits");
}
}
//and here is my class tab:
here is my tab.
int maxImages = 5;
class Images {
PImage[] images = new PImage[maxImages]; // make the image array
//load images into the array with for loop
Images(){
for (int i = 0; i < images.length; i++ ) {
images[i] = loadImage( "p" + i + ".gif");
}
}
void display(){
if(mouseX < 700 && mouseX > 100 && mouseY < 700 && mouseY >100 && mousePressed){
image(images[imageIndex],mouseX, mouseY);
imageIndex = int(random(images.length));
}
}
}
1