Advertisement
xeromino

splattered

Dec 31st, 2013
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1. PImage myImage;
  2. color col;
  3. float sz_max = 30;
  4. float sz_min = sz_max/2;
  5. int max = 10;
  6. float alpha = 200;
  7.  
  8. void setup() {
  9.   background(255);
  10.   colorMode(HSB);  
  11.   noStroke();
  12.   myImage = loadImage("http://media-cache-ec0.pinimg.com/736x/c3/5e/e6/c35ee690c3467e75cd8d607f66357695.jpg");
  13.   size(myImage.width, myImage.height);
  14.   myImage.loadPixels();
  15. }
  16.  
  17. void draw() {
  18.  
  19.   for (int i=0; i<max; i++) {
  20.     int x = int(random(width));
  21.     int y = int(random(height));
  22.     col = myImage.pixels[y*width+x];
  23.     float d = dist(width/2, height/2, x, y);
  24.     float maxDist = width/1.5;
  25.     float var = map(d, 0, maxDist, 10, 1);
  26.     float sz = map(d, 0, maxDist, sz_max, sz_min);
  27.     float r = random(1, 10);
  28.     if (r < var) {
  29.       fill(col, alpha);
  30.       ellipse(x, y, sz, sz);
  31.     }
  32.   }
  33. }
  34.  
  35. void mouseClicked() {
  36.   sz_max -= 5;
  37.   sz_min = sz_max/2;
  38.   max *= 1.4;
  39.   alpha -=30;
  40. }
  41.  
  42. void keyPressed() {
  43.   save(random(1234)+".png");
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement