Advertisement
xeromino

psycho

Oct 20th, 2014
426
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.33 KB | None | 0 0
  1. PImage imgMod, imgOrg;
  2. int num = 50;
  3.  
  4. void setup() {
  5.   imgMod = loadImage("psycho_mod.jpg");
  6.   imgOrg = loadImage("psycho_original.jpg");
  7.   size(imgMod.width, imgMod.height);
  8.   image(imgMod, 0, 0);
  9.   createStuff();
  10. }
  11.  
  12. void draw() {
  13. }
  14.  
  15. void mouseClicked() {
  16.   createStuff();
  17. }
  18.  
  19. void keyPressed() {
  20.   if (key=='d') {
  21.     num += 20;
  22.     println(num);
  23.   }
  24.   if (key=='n') {
  25.     tint(255, 255);
  26.     image(imgMod, 0, 0);
  27.   }
  28.   if (key=='s') saveFrame("image-###.jpg");
  29. }
  30.  
  31. void createStuff() {
  32.   //image(imgMod, 0, 0);
  33.   for (int i=0; i<num; i++) {
  34.     int x = (int) random(380, 880);
  35.     int y = (int) random(0, 420);
  36.     int szX = (int) random(10, 150);
  37.     int szY = (int) random(10, 150);
  38.     float rx = 0;
  39.     if (x<630) {      
  40.       rx = random(-width/2,0);
  41.     } else {
  42.       rx = random(0, width/2);
  43.     }
  44.     float ry = random(-50, 20);
  45.     PImage imgTemp = createImage(szX, szY, RGB);
  46.     imgTemp.loadPixels();
  47.     int j=0;
  48.     for (int py=y; py<y+szY; py++) {
  49.       for (int px=x; px<x+szX; px++) {
  50.         imgTemp.pixels[j]=imgOrg.get(px, py);
  51.         j++;
  52.       }
  53.     }
  54.     imgTemp.updatePixels();
  55.     float distance = dist(x+rx, y+ry, width/2, 210);
  56.     println(distance);
  57.     float alpha = map(distance, 0, width/2, 150, 0);
  58.     tint(255, alpha);
  59.     image(imgTemp, x+rx, y+ry);
  60.   }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement