nicatronTg

Untitled

Apr 19th, 2012
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. int addCircles = 10;
  2. int totalCircles = 10000000;
  3. int circleCount = 0;
  4. float circleDrift = 5;
  5. Circle[] storeCircles = new Circle[totalCircles];
  6.  
  7. void setup() {
  8. size(500,500);
  9. background(255);
  10. smooth();
  11. strokeWeight(1);
  12. fill(150, 50);
  13. newCircles();
  14. }
  15.  
  16. void draw() {
  17. background(255);
  18. for (int i = 0; i < circleCount; i++) {
  19. storeCircles[i].moveMe();
  20. storeCircles[i].drawMe();
  21. storeCircles[i].dontBeAnIdiotAndDriftOffScreenMeAlsoFollowingNamingConventionsForTheWin();
  22. }
  23. }
  24.  
  25. void mouseReleased() {
  26. newCircles();
  27. }
  28.  
  29. void newCircles() {
  30. for (int i = 0; i < addCircles; i++){
  31. Circle c = new Circle();
  32. if (circleCount < totalCircles) {
  33. storeCircles[circleCount] = c;
  34. circleCount += 1;
  35. }
  36. }
  37. }
  38.  
  39. class Circle {
  40.  
  41. float x, y, moveX, moveY;
  42. float radius;
  43. color linecol, fillcol;
  44. float alph;
  45.  
  46. Circle () {
  47. x = random(width);
  48. y = random(height);
  49. radius = random(100) + 10;
  50. linecol = color(random(255), random(255), random(255));
  51. fillcol = color(random(255), random(255), random(255));
  52. alph = random(255);
  53. moveX = random(circleDrift) - circleDrift/2;
  54. moveY = random(circleDrift) - circleDrift/2;
  55. }
  56.  
  57. void drawMe() {
  58. noStroke();
  59. fill(fillcol, alph);
  60. ellipse(x, y, radius*2, radius*2);
  61. stroke(linecol, 150);
  62. noFill();
  63. ellipse(x, y, 10, 10);
  64. }
  65.  
  66. void moveMe() {
  67. x += moveX;
  68. y += moveY;
  69. }
  70.  
  71. void dontBeAnIdiotAndDriftOffScreenMeAlsoFollowingNamingConventionsForTheWin()
  72. {
  73. if (x >= 500)
  74. {
  75. x -= 1;
  76. moveX = random(circleDrift) - circleDrift/2;
  77. } else if (x <= 0)
  78. {
  79. x += 1;
  80. moveX = random(circleDrift) - circleDrift/2;
  81. }
  82. if (y >= 500)
  83. {
  84. y -= 1;
  85. moveY = random(circleDrift) - circleDrift/2;
  86. } else if ((y <= 0))
  87. {
  88. y += 1;
  89. moveY = random(circleDrift) - circleDrift/2;
  90. }
  91. }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment