Advertisement
xeromino

mix

Jun 25th, 2015
440
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.93 KB | None | 0 0
  1. PImage tmp;
  2. PImage[] img = new PImage[2];
  3. int x, y, w, h, r=100, r2=100;
  4. int num = int(map(r2,0,100,10000,2000));
  5.  
  6. void setup() {
  7.   img[0] = loadImage("3.jpg");
  8.   img[1] = loadImage("4.jpg");
  9.   size(img[0].width, img[0].height);
  10.   initStuff();
  11. }
  12.  
  13. void draw() {
  14. }
  15.  
  16. void mouseReleased() {
  17.   background(255);
  18.   initStuff();
  19. }
  20.  
  21. void keyPressed() {
  22.   save(num+".jpg");
  23. }
  24.  
  25. void doStuff(int v, float v1, float v2) {
  26.   w = (int) random(r2, 3*r2);
  27.   h = (int) random(r2, 3*r2);
  28.   x = (int) random(v1, v2-w);
  29.   y = (int) random(height-h);
  30.   tmp = createImage(w, h, RGB);
  31.   tmp.loadPixels();
  32.   int c=0;
  33.   for (int j=0; j<h; j++) {
  34.     for (int i=0; i<w; i++) {
  35.       tmp.pixels[c] = img[v].get(x+i, y+j);
  36.       c++;
  37.     }
  38.   }
  39.   tint(255, 100);
  40.   image(tmp, x+random(-r, r), y+random(-r, r));
  41. }
  42.  
  43. void initStuff() {
  44.   for (int i=0; i<num; i++) {
  45.     doStuff(0, 0, width/2);
  46.     doStuff(1, width/2, width);
  47.   }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement