Advertisement
xeromino

dots

Oct 29th, 2014
454
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.90 KB | None | 0 0
  1. PImage img;
  2. int step=25, num=5, counter;
  3.  
  4. void setup() {
  5.   img = loadImage("http://www.cnsnews.com/sites/default/files/images/freeman%20%202_1.jpg");
  6.   size(img.width, img.height);
  7.   colorMode(HSB, 360, 100, 100);
  8.   background(#eeeeee);
  9.   noStroke();
  10.   for (int y=step/2; y<height; y+=step) {
  11.     for (int x=step/2; x<width-step; x+=step) {
  12.       float offSet=counter%2==0?0:step/2;
  13.       for (int i=0; i<num; i++) {
  14.         float dv = map(i, 0, num-1, -3, 3);
  15.         float sz = map(i, 0, num, step*1.2, step/2);
  16.         color col = img.get(int(x+dv+offSet), int(y+dv));
  17.         float h = hue(col);
  18.         float s = saturation(col);
  19.         float b = brightness(col);
  20.         fill(h, s, b);
  21.         float scal=map(b, 0, 255, 1, 0);
  22.         ellipse(x+offSet, y, sz*scal, sz*scal);
  23.       }
  24.     }  
  25.     counter++;
  26.   }
  27. }
  28.  
  29. void draw() {
  30. }
  31.  
  32. void keyPressed() {
  33.   save(random(3234)+".jpg");
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement