Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Re : Creating a "choose and zoom image" program

$
0
0


like this with arrays

(tested)


  1. //
  2. int indexBigImage = -1;
  3. //
  4. PImage big [] = new PImage [7];
  5. //
  6. PImage small [] = new PImage [7];
  7. //
  8. void setup()
  9. {
  10.   size(800, 600);
  11.   //
  12.   big[1] = loadImage("0big.jpg");
  13.   big[2] = loadImage("1big.jpg");
  14.   big[3] = loadImage("2big.jpg");
  15.   big[4] = loadImage("3big.jpg");
  16.   big[5] = loadImage("4big.jpg");
  17.   big[6] = loadImage("5big.jpg");
  18.   //
  19.   small[1] = loadImage("0small.jpg");
  20.   small[2] = loadImage("1small.jpg");
  21.   small[3] = loadImage("2small.jpg");
  22.   small[4] = loadImage("3small.jpg");
  23.   small[5] = loadImage("4small.jpg");
  24.   small[6] = loadImage("5small.jpg");
  25.   //
  26. }
  27. void draw()
  28. {
  29.   background (255);
  30.   // use for loop here
  31.   image (small[1], 100, 20);
  32.   image (small[2], 200, 20);
  33.   image (small[3], 300, 20);
  34.   image (small[4], 400, 20);
  35.   image (small[5], 500, 20);
  36.   image (small[6], 600, 20);
  37.   //
  38.   if (indexBigImage != -1)
  39.   {
  40.     image (big[indexBigImage], 60, 120);
  41.   }
  42.   //
  43.   if (mouseX>100&&mouseX<180&&mouseY>10&&mouseY<80)
  44.   {
  45.     indexBigImage=1;
  46.   }
  47.   else if (mouseX>200&&mouseX<280&&mouseY>10&&mouseY<80)
  48.   {
  49.     indexBigImage = 2;
  50.   }
  51.   else
  52.   {
  53.     indexBigImage = -1;
  54.   } // else
  55.   //
  56. } // func
  57. //


Viewing all articles
Browse latest Browse all 1768

Trending Articles