Advertisement
xeromino

split

Feb 23rd, 2014
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.87 KB | None | 0 0
  1. PImage img, img2;
  2. int div = 15;
  3. int step = 5;
  4. float scal = 1.5;
  5.  
  6. void setup() {
  7.   img = loadImage("h1.jpg");
  8.   img2 = loadImage("h2.jpg");
  9.   size(img.width, img.height);
  10.   //size(480, 500);
  11.  
  12.   //distort();
  13. }
  14.  
  15. void draw() {
  16.   distort();
  17. }
  18.  
  19. void distort() {
  20.   int stepx = (int) width/div;
  21.   int stepy = (int) height/div;
  22.  
  23.   for (int y=0; y<height; y += stepy) {
  24.     for (int x=0; x<width; x += stepx) {
  25.       float rx = random(-step, step);
  26.       float ry = random(-step, step);
  27.       if (x > width/2) {
  28.         copy(img2, x, y, stepx, stepy, int(x + rx), int(y+ry), int(stepx*scal), int(stepy*scal));
  29.       }
  30.       else {
  31.         copy(img, x, y, stepx, stepy, int(x + rx), int(y+ry), int(stepx*scal), int(stepy*scal));
  32.       }
  33.       stroke(255);
  34.       strokeWeight(5);
  35.       noFill();
  36.     }
  37.   }
  38. }
  39. void mouseClicked() {
  40.   saveFrame("image-###.gif");
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement