Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PImage img;
- void setup() {
- background(220);
- img = loadImage("http://i.imgur.com/zRbqFzW.jpg");
- size(img.width, img.height);
- }
- void draw() {
- for (int i=0; i<200; i++) {
- // calculate start point for the line
- PVector start = new PVector(random(width), random(height));
- // calculate end point
- float a = TAU * 2 * noise(map(start.x, 0, width, 0, 4), map(start.y, 0, height, 0, 4));
- PVector end = PVector.fromAngle(a);
- float len = random(3, 15);
- end.mult(len);
- end.add(start);
- // calculate color
- PVector pointInImage = new PVector(map(start.x, 0, width, 0, img.width), map(start.y, 0, height, 0, img.height));
- color c = img.get((int)pointInImage.x, (int)pointInImage.y);
- // draw
- stroke(c,50);
- strokeWeight(random(2, 6));
- line(start.x, start.y, end.x, end.y);
- }
- }
- void keyPressed() {
- save(random(233)+".jpg");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement