emailconfirmed
1,824
edits
No edit summary |
(improve homework III (flickr!)) |
||
Line 277: | Line 277: | ||
<source lang="java"> | <source lang="java"> | ||
int n = 10; | int n = 10; | ||
// list of flickr urls, containing my images | |||
String[] urls = { | |||
"https://c1.staticflickr.com/1/583/23143686064_f334ac29d3_c.jpg", | |||
"https://c1.staticflickr.com/1/744/23145048033_5e4ca63da7_c.jpg", | |||
"https://c1.staticflickr.com/6/5774/23771836845_a9bfd0e883_c.jpg", | |||
"https://c1.staticflickr.com/6/5715/23403900079_6d7e2fbd96_c.jpg", | |||
"https://c1.staticflickr.com/6/5815/23663367172_c647395930_c.jpg", | |||
"https://c1.staticflickr.com/1/721/23663365892_fa35e2156a_c.jpg", | |||
"https://c1.staticflickr.com/6/5654/23476155410_dfaa2d34e5_c.jpg", | |||
"https://c1.staticflickr.com/1/781/23689409061_eb23a1cfd3_c.jpg", | |||
"https://c1.staticflickr.com/1/614/23403891279_54d675d8db_c.jpg", | |||
"https://c1.staticflickr.com/6/5695/23403888729_3caefaf24a_c.jpg" | |||
}; | |||
PImage[] images = new PImage[n]; | PImage[] images = new PImage[n]; | ||
Line 292: | Line 308: | ||
float speed = 0.005; | float speed = 0.005; | ||
void setup() { | void setup() { | ||
// canvas size | // canvas size | ||
size(600, 400); | size(600, 400); | ||
// start out with a white background | // start out with a white background | ||
background(255); | background(255); | ||
// load images into the array using a loop | // load images into the array using a loop | ||
for(int i=0; i < n; i++) { | for(int i=0; i < n; i++) { | ||
// load the image | // load the image | ||
images[i] = loadImage( | images[i] = loadImage(urls[i]); | ||
// Use the brightness of the image as its own alpha channel | // Use the brightness of the image as its own alpha channel | ||
// As a result the dark parts of the image will become more transparent | // As a result the dark parts of the image will become more transparent | ||
// Nota Bene: This is a hack :) | // Nota Bene: This is a hack :) | ||
images[i].mask(images[i]); | images[i].mask(images[i]); | ||
noCursor(); | |||
} | } | ||
} | } | ||
Line 326: | Line 344: | ||
// restore the previous transformation matrix | // restore the previous transformation matrix | ||
popMatrix(); | popMatrix(); | ||
// pick the index of an image | // pick the index of an image | ||
int pick = (frameCount / slowdown) % n; | int pick = (frameCount / slowdown) % n; | ||
Line 335: | Line 353: | ||
// scale the image | // scale the image | ||
scale(zoom); | scale(zoom); | ||
// move to the reference point | // move to the reference point | ||
translate(-dx, -dy); | translate(-dx, -dy); | ||
// get image from the array and display it | // get image from the array and display it | ||
image(images[pick], 0, 0); | image(images[pick], 0, 0); |