GMU:Processing im Park/Maike Effenberg/HW3 2

From Medien Wiki
< GMU:Processing im Park‎ | Maike Effenberg
Revision as of 22:10, 13 January 2016 by Bhgvt (talk | contribs) (Created page with "== Code - Homework 3.1 == <source lang = "java"> int n = 12; PImage[] images = new PImage[n]; // offset to the reference point int dx = 100; int dy = 200; // factor to slow ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Code - Homework 3.1

int n = 12; 
PImage[] images = new PImage[n];

// offset to the reference point 
int dx = 100;
int dy = 200;

// factor to slow our animation down
int slowdown = 10;

// zoom factor for our image
float zoom = 0.1;

void setup() {
  
  // canvas size
  size(600, 600);
  
  //  background
  background(120);
  
  // load images into the array using a loop 
  for(int i=0; i < n; i++) {
    
    // load the image
    images[i] = loadImage("schwarn" + i + ".jpg");
    

    // the hack !
    images[i].mask(images[i]);
 
  }
  
}


void draw() {
  
  // pick the index of an image
  int pick = (frameCount / slowdown) % n;

  // move to the mouse position 

  translate(mouseX -dx/2 , mouseY -dy/2);

  // scale the image
  scale(zoom);
  
  // move to the reference point
  translate(-dx, -dy);
  
  // get image from the array and display it
  image(images[pick], 0, 0); 

}