Sketch for Toward...: Difference between revisions

From XPUB & Lens-Based wiki
(Created page with "<source lang="java"> </source> thumbnail")
 
No edit summary
 
Line 1: Line 1:
<source lang="java">
<source lang="java">
PImage currentImage;  // only the current image gets displayed
PImage img1;      // we have 16 images in store
PImage img2;
PImage img3;
PImage img4;
PImage img5;
PImage img6;
PImage img7;
PImage img8;
PImage img9;
PImage img10;
PImage img11;
PImage img12;
PImage img13;
PImage img14;
PImage img15;
PImage img16;


int myImageNumber = 0; // represents the current image number
int timer = millis();
void setup() {
size (795,1064);
img1=loadImage("toward0.jpg");
img2=loadImage("toward1.jpg");
img3=loadImage("toward2.jpg");
img4=loadImage("toward3.jpg");
img5=loadImage("toward4.jpg");
img6=loadImage("toward5.jpg");
img7=loadImage("toward6.jpg");
img8=loadImage("toward7.jpg");
img9=loadImage("toward8.jpg");
img10=loadImage("toward9.jpg");
img11=loadImage("toward10.jpg");
img12=loadImage("toward11.jpg");
img13=loadImage("toward12.jpg");
img14=loadImage("toward13.jpg");
img15=loadImage("toward14.jpg");
img16=loadImage("toward15.jpg");
currentImage=img1;  // or copy, I don't know
}
void draw () {
  image(currentImage, 0, 0);
if (timer+4000 < millis()) {
    redraw();
    timer = millis();
  }
}
void mousePressed() {
  // set the current image number
  if (mouseButton == LEFT) {
        myImageNumber++;
    if (myImageNumber>15) {
    myImageNumber=0;
     
}
}
  // use the current image number to set the current image (it gets displayed)
switch (myImageNumber) {
case 0:
currentImage=img1;
break;
case 1:
currentImage=img2;
break;
case 2:
currentImage=img3;
break;
case 3:
currentImage=img4;
break;
case 4:
currentImage=img5;
break;
case 5:
currentImage=img6;
break;
case 6:
currentImage=img7;
break;
case 7:
currentImage=img8;
break;
case 8:
currentImage=img9;
break;
case 9:
currentImage=img10;
break;
case 10:
currentImage=img11;
break;
case 11:
currentImage=img12;
break;
case 12:
currentImage=img13;
break;
case 13:
currentImage=img14;
break;
case 14:
currentImage=img15;
break;
case 15:
currentImage=img16;
break;
}
}
</source>
</source>
[[File:Testtttt.jpg|thumbnail]]
[[File:Testtttt.jpg|thumbnail]]

Latest revision as of 18:44, 8 December 2017

PImage currentImage;  // only the current image gets displayed
PImage img1;      // we have 16 images in store
PImage img2; 
PImage img3;
PImage img4;
PImage img5;
PImage img6;
PImage img7;
PImage img8;
PImage img9;
PImage img10;
PImage img11;
PImage img12;
PImage img13;
PImage img14;
PImage img15;
PImage img16;

int myImageNumber = 0; // represents the current image number
int timer = millis(); 
void setup() {
size (795,1064);
img1=loadImage("toward0.jpg");
img2=loadImage("toward1.jpg");
img3=loadImage("toward2.jpg");
img4=loadImage("toward3.jpg");
img5=loadImage("toward4.jpg");
img6=loadImage("toward5.jpg");
img7=loadImage("toward6.jpg");
img8=loadImage("toward7.jpg");
img9=loadImage("toward8.jpg");
img10=loadImage("toward9.jpg");
img11=loadImage("toward10.jpg");
img12=loadImage("toward11.jpg");
img13=loadImage("toward12.jpg");
img14=loadImage("toward13.jpg");
img15=loadImage("toward14.jpg");
img16=loadImage("toward15.jpg");
currentImage=img1;   // or copy, I don't know
}

void draw () {
  image(currentImage, 0, 0);
 if (timer+4000 < millis()) { 
    redraw();
    timer = millis();
  }
}
void mousePressed() {
   // set the current image number
  if (mouseButton == LEFT) {
        myImageNumber++;
    if (myImageNumber>15) {
     myImageNumber=0;
 
       
}
}
  // use the current image number to set the current image (it gets displayed)
 switch (myImageNumber) {
case 0:
currentImage=img1;
break; 
case 1:
currentImage=img2;
break; 
 case 2:
currentImage=img3;
break; 
 case 3:
currentImage=img4;
break;
 case 4:
currentImage=img5;
break;
 case 5:
currentImage=img6;
break;
 case 6:
currentImage=img7;
break;
 case 7:
currentImage=img8;
break;
 case 8:
currentImage=img9;
break;
 case 9:
currentImage=img10;
break;
 case 10:
currentImage=img11;
break;
 case 11:
currentImage=img12;
break;
 case 12:
currentImage=img13;
break;
 case 13:
currentImage=img14;
break;
 case 14:
currentImage=img15;
break;
 case 15:
currentImage=img16;
break;

} 
}