Advertisement
xeromino

torch

Nov 5th, 2014
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.81 KB | None | 0 0
  1. PImage img;
  2. float py;
  3. int frames = 72;
  4.  
  5. void setup() {
  6.   img = loadImage("http://media-cache-ak0.pinimg.com/736x/f4/34/85/f43485adbf64b6f3a0b449820aec3703.jpg");
  7.   size(img.width, img.height);
  8.   image(img, 0, 0);
  9.   py = -height/3;
  10. }  
  11.  
  12. void draw() {
  13.   loadPixels();
  14.   img.loadPixels();
  15.   float scope = height*.4;
  16.   for (int x=0; x<width; x++) {
  17.     for (int y=0; y<height; y++) {
  18.       int loc = x+y*width;
  19.       float r = red(img.pixels[loc]);
  20.       float g = green(img.pixels[loc]);
  21.       float b = blue(img.pixels[loc]);
  22.       float d = dist(width/2, py, x, y);
  23.       float factor = map(d, 0, scope, 1, 0);
  24.       pixels[loc]=color(r*factor, g*factor, b*factor);
  25.     }
  26.   }
  27.   updatePixels();
  28.   py += (height+2*scope)/frames;
  29.   saveFrame("image-###.gif");
  30.   if (frameCount==frames) noLoop();
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement