Advertisement
xeromino

hires

Oct 29th, 2014
671
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.16 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.   drawImage();
  8. }
  9.  
  10. void draw() {
  11. }
  12.  
  13. void keyPressed() {
  14.   saveHiRes(4);
  15. }
  16.  
  17. void drawImage() {
  18.   colorMode(HSB, 360, 100, 100);
  19.   background(#eeeeee);
  20.   noStroke();
  21.   for (int y=step/2; y<height; y+=step) {
  22.     for (int x=step/2; x<width-step; x+=step) {
  23.       float offSet=counter%2==0?0:step/2;
  24.       for (int i=0; i<num; i++) {
  25.         float dv = map(i, 0, num-1, -3, 3);
  26.         float sz = map(i, 0, num, step*1.1, step/2);
  27.         color col = img.get(int(x+dv+offSet), int(y+dv));
  28.         float h = hue(col);
  29.         float s = saturation(col);
  30.         float b = brightness(col);
  31.         fill(h, s, b);
  32.         float scal=map(b, 0, 255, 1, 0);
  33.         ellipse(x+offSet, y, sz*scal, sz*scal);
  34.       }
  35.     }  
  36.     counter++;
  37.   }
  38. }
  39.  
  40. void saveHiRes(int scaleFactor) {
  41.   PGraphics hires = createGraphics(width*scaleFactor, height*scaleFactor, JAVA2D);
  42.   beginRecord(hires);
  43.   hires.scale(scaleFactor);
  44.   drawImage();
  45.   endRecord();
  46.   hires.save("render.png");
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement