Advertisement
xeromino

rays

Jan 6th, 2014
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.92 KB | None | 0 0
  1. PImage myImage;
  2. color col;
  3. float sw, br, incr;
  4. PVector ray;
  5.  
  6. void setup() {
  7.   background(0);
  8.   colorMode(HSB, 100);
  9.   myImage = loadImage("http://media-cache-ak0.pinimg.com/736x/d2/49/ac/d249ac18b4a86e9a6383e5c2909eabf1.jpg");
  10.   size(myImage.width, myImage.height);
  11.   myImage.loadPixels();
  12.   incr = 5;
  13.   image(myImage, 0, 0);
  14.   ray = new PVector(random(1,2), random(1,2));
  15.   ray.normalize();
  16.   ray.mult(int(random(10,150)));
  17.  
  18.   for (int x = 0;  x<width; x += incr) {
  19.     for (int y = 0; y < height; y += incr) {
  20.       col = myImage.pixels[y*width+x];
  21.       sw = map(brightness(myImage.get(x, y)), 0, 100, 20, 40) ;
  22.       br = brightness(myImage.get(x, y));
  23.      
  24.       println(ray);
  25.       if (br>50) {
  26.         stroke(myImage.get(x, y), random(255));
  27.         strokeWeight(1);
  28.         line(x, y,x+ray.x,y-ray.y);
  29.       }
  30.     }
  31.   }
  32. }
  33.  
  34. void draw() {
  35.  
  36. }
  37.  
  38. void keyPressed() {
  39.   save(random(123)+".png");
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement