Advertisement
xeromino

pix

Oct 23rd, 2015
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.98 KB | None | 0 0
  1. PImage img;
  2. int rez=10;
  3. long nS = (long) random(12345);
  4.  
  5. void setup() {
  6.   size(540, 540);
  7.   img = loadImage("pic.jpg");
  8.   image(img, 0, 0);
  9.   surface.setResizable(true);
  10.   surface.setSize(img.width, img.height);
  11.   //pixelNoise();
  12. }
  13.  
  14. void draw() {
  15.   pixelNoise();
  16. }
  17.  
  18. void pixelNoise() {
  19.   noiseSeed(nS);
  20.   image(img, 0, 0);
  21.   float yOff = 0;
  22.   for (int x=0; x<img.width; x +=rez) {
  23.     float xOff=0;
  24.     for (int y=0; y<img.height; y+=rez) {
  25.       color c = img.get(x+rez/2, y+rez/2);
  26.       fill(c);
  27.       stroke(255, 50);
  28.       float ns = noise(xOff, yOff);
  29.       if (ns>0.5) {
  30.         fill(c);
  31.         stroke(255, 50);
  32.         rect(x, y, rez, rez);
  33.       }
  34.       ns = noise(xOff-0.8, yOff+0.7);
  35.       if (ns>0.7) {
  36.         fill(255);
  37.         noStroke();
  38.         rect(x, y, rez, rez);
  39.       }
  40.       xOff += 0.05;
  41.     }
  42.     yOff += 0.06;
  43.   }
  44. }
  45.  
  46. void mouseClicked() {
  47.   nS = (long) random(12345);
  48. }
  49.  
  50. void keyPressed() {
  51.   save(random(1234)+".jpg");
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement