Advertisement
xeromino

glitchBr

May 8th, 2015
515
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.77 KB | None | 0 0
  1. PImage img;
  2. int min = 40, max = 80;
  3. int r = 10;
  4.  
  5. void setup() {
  6.   img = loadImage("https://s-media-cache-ak0.pinimg.com/736x/2c/f6/a5/2cf6a58f75b368949cf98db03b925f1b.jpg");
  7.   size(img.width, img.height);
  8.   image(img, 0, 0);
  9. }
  10.  
  11. void draw() {
  12.   doStuff();
  13. }
  14.  
  15. void keyPressed() {
  16.   save(random(123456)+".jpg");
  17. }
  18.  
  19. void doStuff() {
  20.   PImage tmp = createImage(width, height, RGB);
  21.   tmp.loadPixels();
  22.   float rd = random(25, 100);
  23.   for (int px=0; px<width; px++) {
  24.     for (int py=0; py<height; py++) {
  25.       float br = brightness(img.get(px, py));
  26.       if (br>rd) tmp.pixels[py*width+px]=get(px, py);
  27.     }
  28.   }
  29.   tmp.updatePixels();
  30.   int v = (int)random(-r, r);
  31.   int v2 = (int)random(-r, r);
  32.   image(tmp, v, v2);
  33. }
  34.  
  35. void mouseClicked() {
  36.   //doStuff();
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement