Advertisement
xeromino

abe_noise

May 21st, 2014
429
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.89 KB | None | 0 0
  1. PImage img;
  2. void setup() {
  3.   background(220);
  4.   img = loadImage("http://i.imgur.com/zRbqFzW.jpg");
  5.   size(img.width, img.height);
  6. }
  7. void draw() {
  8.   for (int i=0; i<200; i++) {
  9.     // calculate start point for the line
  10.     PVector start = new PVector(random(width), random(height));
  11.  
  12.     // calculate end point
  13.     float a = TAU * 2 * noise(map(start.x, 0, width, 0, 4), map(start.y, 0, height, 0, 4));
  14.     PVector end = PVector.fromAngle(a);
  15.     float len = random(3, 15);
  16.     end.mult(len);
  17.     end.add(start);
  18.  
  19.     // calculate color
  20.     PVector pointInImage = new PVector(map(start.x, 0, width, 0, img.width), map(start.y, 0, height, 0, img.height));
  21.     color c = img.get((int)pointInImage.x, (int)pointInImage.y);
  22.  
  23.     // draw
  24.     stroke(c,50);
  25.     strokeWeight(random(2, 6));
  26.     line(start.x, start.y, end.x, end.y);
  27.   }
  28. }
  29.  
  30. void keyPressed() {
  31.   save(random(233)+".jpg");
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement