changing images like a "page"
in
Programming Questions
•
1 year ago
so i have 4 images. based on the furthest point of an "X" coordinate, i want to shuffle through them like book pages.
so you have main image, if x > "a value" .... turn to next. next image is loaded. once x is met again, shuffle to next image and so fourth.
heres what I've got so far:
- /**
- * Load and Display
- *
- * Images can be loaded and displayed to the screen at their actual size
- * or any other size.
- */
- // The next line is needed if running in JavaScript Mode with Processing.js
- /* @pjs preload="moonwalk.jpg"; */
- PImage img;
- PImage img2;
- PImage img3; // Declare variable "a" of type PImage
- void setup() {
- size(640, 360);
- // The image file must be in the data folder of the current sketch
- // to load successfully
- img = loadImage("infographic1.png");
- img2 = loadImage("infographic2.png");
- img3 = loadImage("infographic3.png"); // Load the image into the program
- }
- void draw() {
- // Displays the image at its actual size at point (0,0)
- image(img, 0, 0, 640, 400);
- line(mouseX, 20, mouseX, 80);
- println(mouseX);
- while(img ==img && mouseX > 500){
- image(img2, 0, 0, 640, 400);
- break;
- }
- while(img2 ==img2 && mouseX > 500){
- image(img3, 0, 0, 640, 400);
- break;
- }
- }
1