Advertisement
xeromino

pixelcam

Jun 21st, 2014
416
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.97 KB | None | 0 0
  1. PImage img;
  2. int bg = 0, ty=10, cols = 40;
  3. float x, sz;
  4. boolean on = true;
  5.  
  6. void setup() {
  7.   size(1000, 500);
  8.   background(bg);
  9.   img = loadImage("photo.jpg");
  10.   frameRate(15);
  11.   x = width/2;
  12. }
  13.  
  14. void draw() {
  15.   /*if (on) {
  16.     img = loadImage("photo.jpg");
  17.   } else {
  18.     img = loadImage("photo2.jpg");
  19.   }
  20.   */
  21.   rectMode(CENTER);
  22.   color f = img.get(int(x-width/2), ty);
  23.   float w = width/2/cols+random(-10, 10);
  24.   float h = map(brightness(f), 0, 255, height*.1, height*.8);
  25.   float a = map(brightness(f), 0, 255, 150, 35);
  26.   fill(f, a);
  27.   noStroke();
  28.   rect(x, height/2, w, h, 5);  
  29.   x += w;
  30.   if (x>width-10) {
  31.     x=width/2;
  32.     ty += (height*.1+random(-5, 5));
  33.     if (ty>height) ty=0;
  34.   }
  35.   fill(bg);
  36.   noStroke();
  37.   //rectMode(CORNER);
  38.   copy(img, 0, 0, 500, height, 0, 0, 500, height);
  39.   stroke(255);
  40.   noFill();
  41.   ellipse(x-width/2, ty, 10, 10);
  42.   if (frameCount%100==0) on =! on;
  43. }
  44.  
  45. void mouseReleased() {
  46.   saveFrame("image-###.jpg");
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement