Advertisement
xeromino

eyes

Feb 23rd, 2014
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1. PImage img;
  2. int div = 15;
  3. int step = 5;
  4. float scal = 1.5;
  5.  
  6. void setup() {
  7.   img = loadImage("a.jpg");
  8.   //size(img.width, img.height);
  9.   size(500,500);
  10.  
  11.   //distort();
  12. }
  13.  
  14. void draw() {
  15.   distort();
  16.  
  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.       copy(img, x, y, stepx, stepy, int(x + rx), int(y+ry), int(stepx*scal), int(stepy*scal));
  28.       stroke(255);
  29.       strokeWeight(5);
  30.       noFill();
  31.     }
  32.   }
  33. }
  34. void mouseClicked() {
  35.   saveFrame("image-###.gif");
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement