Image Array

JwSJwS
edited February 2014 in How To...

Hello,

My objective: Make a random image generator where there are 10 (tall and skinny) images next to each other, and when the mouse enters a quadrant the picture changes (to one of the other…say 30 pictures).

I have read and watched a lot of tutorials, but I am having trouble even beginning this successfully.

I know that I want a canvas something like 1000, 8000 and have each picture take up 100,800.

Any help will be greatly appreciated.

Answers

  • edited February 2014
        PImage[] img = new PImage[1];
        void setup() {
          size(1000, 800);
          noStroke();
          String hack = "http:"
          img[0] = loadImage(hack + "//www.tfguy44.com/MyIcon1.PNG");
        }
    
        void draw() {
          background(0);
          for (int i=0;i<10;i++) {
            fill(random(255), random(255), random(255));
            rect(100*i, 0, 100, height);
          }
          image(img[0], (width-img[0].width)/2, (height-img[0].height)/2);
        }
    
  • Ok, something is screwy with the formatting here, I can't post the plain URL for my image.

    You get the idea though.

  • _vk_vk
    edited February 2014

    It's a forum issue. I usually do:

    String hack = "http:";
    loadImage(hack + "//someurl.com");
    

    :P

Sign In or Register to comment.