xeromino

swarm

Aug 8th, 2014
559
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. int c, num=2500;
  2. PImage img;
  3. PVector[] start;
  4. PVector[] end;
  5. color[] col=new color[num];
  6. float lerpValue, angle;
  7.  
  8. void setup() {
  9. randomSeed(20);
  10. size(500, 500);
  11. background(255);
  12. img = loadImage("earth.jpg");
  13. colorMode(HSB, 100, 100, 100);
  14. start = new PVector[num];
  15. end = new PVector[num];
  16. while (c<num) {
  17. int x = (int)random(width);
  18. int y = (int)random(height);
  19. color br = img.get(x, y);
  20. if (brightness(br)<50) {
  21. float _x = width/2 + sin(angle)*width*.5;
  22. float _y = height/2 + cos(angle)*height*.5;
  23. start[c] = new PVector(_x, _y);
  24. end[c]= new PVector(x, y);
  25. col[c] = br;
  26. c++;
  27. angle += radians(1.7);
  28. }
  29. }
  30. }
  31.  
  32. void draw() {
  33. //background(#ffffff);
  34. fill(#ffffff, 100);
  35. noStroke();
  36. rect(0, 0, width, height);
  37. for (int i=0; i<c; i++) {
  38. fill(#202020);
  39. noStroke();
  40. float currentX = lerp(start[i].x, end[i].x, lerpValue);
  41. float currentY = lerp(start[i].y, end[i].y, lerpValue);
  42. ellipse(currentX, currentY, 3, 3);
  43. }
  44. lerpValue += 0.006;
  45. if (lerpValue>1) noLoop();
  46. }
Advertisement
Add Comment
Please, Sign In to add comment