Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ArrayList<Dot> dots;
- int num = 7000, d=20, br=180, alpha=40;
- int bg=255, s=0;
- PImage img;
- void setup() {
- img=loadImage("http://media-cache-ec0.pinimg.com/736x/ca/fd/29/cafd29d721cc0302cee4093ec2e34d27.jpg");
- size(img.width, img.height);
- background(bg);
- dots = new ArrayList<Dot>();
- //image(img, 0, 0);
- img.loadPixels();
- for (int i=0; i<num; i++) {
- int x = int(random(width));
- int y = int(random(height));
- if (brightness(img.pixels[x+y*width])<br) {
- dots.add(new Dot(new PVector(x, y)));
- }
- }
- for (Dot d : dots) {
- d.lineBetween();
- }
- }
- void draw() {}
- void keyPressed() {
- save(random(2332)+".jpg");
- }
- class Dot {
- PVector loc;
- Dot(PVector _loc) {
- loc = _loc;
- }
- void lineBetween() {
- for (int i=0; i<dots.size (); i++) {
- Dot other = (Dot) dots.get(i);
- float distance = loc.dist(other.loc);
- if (distance >0 && distance < d) {
- stroke(s, alpha);
- line(loc.x, loc.y, other.loc.x, other.loc.y);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement