Advertisement
xeromino

kids

May 26th, 2014
399
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.29 KB | None | 0 0
  1. PImage img;
  2. float theta;
  3. int slices=200, unit;
  4. PImage[] rSlices = new PImage[slices];
  5. PImage[] lSlices = new PImage[slices];
  6.  
  7. void setup() {
  8.   img = loadImage("twins.jpg");
  9.   size(img.width, img.height);
  10.   unit = height/slices;
  11.   background(255);
  12.   frameRate(15);
  13.  
  14.   for (int i=0; i<slices; i++) {
  15.     rSlices[i] = createImage(width/2, unit, RGB);
  16.     rSlices[i].loadPixels();
  17.     lSlices[i] = createImage(width/2, unit, RGB);
  18.     lSlices[i].loadPixels();
  19.     for (int x=width/2; x<width; x++) {
  20.       for (int y=0; y<unit; y++) {
  21.         rSlices[i].pixels[y*width/2+x-(width/2)]=img.get(x, i*unit);
  22.         lSlices[i].pixels[y*width/2+x-(width/2)]=img.get(x-width/2, i*unit);
  23.       }
  24.     }
  25.     rSlices[i].updatePixels();
  26.     lSlices[i].updatePixels();
  27.     //image(pslices[i], width/2, i*unit);
  28.   }
  29. }
  30.  
  31. void draw() {
  32.   tint(255, 255);
  33.   image(img, 0, 0);
  34.   filter(BLUR);
  35.   tint(255, 150);
  36.   for (int i=0; i<slices; i++) {
  37.     float offSet = map(sin(theta+(TWO_PI/slices*i)), -1, 1, 0, width/4);
  38.     float offSet2 = map(sin(-theta+(TWO_PI/slices*i)), -1, 1, -width/4, 0);
  39.     image(rSlices[i], width/2+offSet, i*unit);
  40.     image(lSlices[i], offSet2, i*unit);
  41.   }
  42.   filter(BLUR);
  43.   theta += .0523;
  44.   //theta += (TWO_PI/15);
  45.   //if (theta<TWO_PI) saveFrame("image-###.gif");
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement