|
|
Line 45: |
Line 45: |
| [[File:chairs_1.gif]] [[File:chairs_2.gif]] | | [[File:chairs_1.gif]] [[File:chairs_2.gif]] |
|
| |
|
| | | [http://www.uni-weimar.de/medien/wiki/GMU:Processing_im_Park/Katja_Bli%C3%9F/code4 Sourcecode] |
| <source lang="java">
| |
| | |
| int n = 3;
| |
| PImage[] images = new PImage[n];
| |
| | |
| // offset to the reference point | |
| int dx = 100;
| |
| int dy = 200;
| |
| | |
| // factor to slow our animation down
| |
| int slowdown = 4;
| |
| | |
| // zoom factor for our image
| |
| float zoom = 0.5;
| |
| | |
| void setup() {
| |
|
| |
| // canvas size
| |
| size(600, 400);
| |
|
| |
| // start out with a white background
| |
| background(255);
| |
|
| |
| // load images into the array using a loop
| |
| for(int i=0; i < n; i++) {
| |
|
| |
| // load the image
| |
| images[i] = loadImage("chair_" + i + ".gif");
| |
|
| |
| | |
| 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 , mouseY);
| |
| | |
| // 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);
| |
| save("image.gif");
| |
| }
| |
| </source>
| |