Random Image Overlapping

Hi! I'm a designer who knows a little of code, but I'm new to coding in Processing.

I'm developing a project to obtain my university degree in Design, and the idea needs to create a overlapping of random images, so I tought Processing could do it easier.

Does any one knows how I can set Processing to load images from different locations and overlap them? Like if I have 3 folders with different images and Processing take one from each one and put above the other.

I am really new to Processing, so I would love if any one could help me with that.

Thank you :)

Tagged:

Answers

  • edited April 2016

    I forgot to post my code. I have writen this using some things I found on web:

    // DECLARE YOUR GLOBAL VARIABLES HERE.
    PImage fragment;
    int rand;
    
    void setup() {
     size(800, 600);
     rand = int(random(0,4)); //Number of random images
     randomimage_background("bg_" + nf(rand, 3) + ".jpg"); //Images must call "bg_XXX.jpg"
    }
    // THIS IS THE FUNCTION
    void randomimage_background(String fn) {
       fragment = loadImage(fn); //LOAD RANDOM IMAGE
       image(fragment,0,0);//DISPLAY RANDOM IMAGE
    }
    

    This works really well to display random images. What I need now is to make it overlap another random images, but they could not be the bg_XXX.jpg images.

    Anyway I could do it?

  • I have just done it, and it looks exactly the way I want!

    // DECLARE YOUR GLOBAL VARIABLES HERE.
    PImage backgroundimage; //IMAGE VARIABLE
    PImage foregroundimage; //IMAGE VARIABLE
    int rand; //RANDOM NUMBER VARIABLE
    int rand2; //RANDOM NUMBER VARIABLE
    
    void setup() {
     size(800, 600);
     rand = int(random(0,4)); //NUMBER OF RANDOM IMAGES
     rand2 = int(random(0,4)); //NUMBER OF RANDOM IMAGES
     randomimage_background("bg_" + nf(rand, 3) + ".jpg"); //IMAGES MUST CALL "bg_XXX.jpg"
     randomimage_foreground("fore_" + nf(rand2, 3) + ".jpg"); //IMAGES MUST CALL "fore_XXX.jpg"
    }
    
    // FUNCTION TO LOAD BACKGROUND
    void randomimage_background(String fn) {
      backgroundimage = loadImage(fn); //LOAD RANDOM IMAGE
      tint(255, 127); //IMAGE TRANSPARENCY
      image(backgroundimage,0,0);//DISPLAY RANDOM IMAGE
    }
    
    // FUNCTION TO LOAD FOREGROUND
    void randomimage_foreground(String fn) {
      foregroundimage = loadImage(fn); //LOAD RANDOM IMAGE
      tint(255, 127); //IMAGE TRANSPARENCY
      image(foregroundimage,0,0); //DISPLAY RANDOM IMAGE
    }
    

    Now I need to make buttons for the user to click and display these images. I tought in Radio buttons to mark what type of images I want to display (like backgroundimage or foregroundimage) and a button to run it.

    Is that possible?

This discussion has been closed.