Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PImage img;
- float py;
- int frames = 72;
- void setup() {
- img = loadImage("http://media-cache-ak0.pinimg.com/736x/f4/34/85/f43485adbf64b6f3a0b449820aec3703.jpg");
- size(img.width, img.height);
- image(img, 0, 0);
- py = -height/3;
- }
- void draw() {
- loadPixels();
- img.loadPixels();
- float scope = height*.4;
- for (int x=0; x<width; x++) {
- for (int y=0; y<height; y++) {
- int loc = x+y*width;
- float r = red(img.pixels[loc]);
- float g = green(img.pixels[loc]);
- float b = blue(img.pixels[loc]);
- float d = dist(width/2, py, x, y);
- float factor = map(d, 0, scope, 1, 0);
- pixels[loc]=color(r*factor, g*factor, b*factor);
- }
- }
- updatePixels();
- py += (height+2*scope)/frames;
- saveFrame("image-###.gif");
- if (frameCount==frames) noLoop();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement