Advertisement
Guest User

Untitled

a guest
Jan 15th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. /*
  2.  
  3. Based on: http://www.dailyminimal.com/post/172999683369/no-142-a-new-geometric-design-every-day
  4. Daily Minimal.
  5.  
  6. */
  7. ArrayList<Planet> planets = new ArrayList<Planet>();
  8. ArrayList<Planet> planetsB = new ArrayList<Planet>();
  9. ArrayList<Planet> planetsT = new ArrayList<Planet>();
  10.  
  11. void setup() {
  12. size(500, 500);
  13. Planet planet1 = new Planet();
  14. planet1.s = 0.002;
  15. planet1.r = 35;
  16. planets.add(planet1);
  17. }
  18.  
  19. float traceOrbit = 500;
  20. float traceOrbit2 = 100;
  21. float rSun = 250;
  22. int i;
  23.  
  24. void draw() {
  25. translate(width/2, height/2);
  26. rotate(radians(-25));
  27. background(233);
  28. planetsB = new ArrayList<Planet>();
  29. planetsT = new ArrayList<Planet>();
  30. for (Planet planet : planets) {
  31. planet.setCoords(millis(), traceOrbit, traceOrbit2);
  32. if (planet.overLapping()) {
  33. planetsB.add(planet);
  34. } else {
  35. planetsT.add(planet);
  36. }
  37. }
  38. printHalfSun(false);
  39. printTrace();
  40. for (Planet planet : planetsT) {
  41. planet.display();
  42. }
  43. for (Planet planet : planetsB) {
  44. planet.display();
  45. }
  46. printHalfSun(true);
  47. makeNoise();
  48. }
  49.  
  50.  
  51. void printHalfSun(boolean top) {
  52. strokeWeight(4);
  53. if (top) {
  54. fill(0);
  55. stroke(233);
  56. arc(0, 0, rSun, rSun, PI, TWO_PI);
  57. } else {
  58. fill(0);
  59. stroke(233);
  60. arc(0, -0.3, rSun, rSun, 0, PI);
  61. }
  62. }
  63.  
  64. void printTrace() {
  65. noFill();
  66. stroke(233);
  67. strokeWeight(12);
  68. ellipse(0, 0, traceOrbit, traceOrbit2);
  69.  
  70. noFill();
  71. stroke(0);
  72. strokeWeight(4);
  73. ellipse(0, 0, traceOrbit, traceOrbit2);
  74. }
  75.  
  76. void mousePressed() {
  77. Planet planet1 = new Planet();
  78. planet1.s = random(0.0001, 0.004);
  79. planet1.r = random(20, 70);
  80. planets.add(planet1);
  81. }
  82.  
  83. void keyPressed(){
  84. planets = new ArrayList<Planet>();
  85. }
  86.  
  87. void makeNoise() {
  88. rotate(radians(25));
  89. noStroke();
  90. strokeWeight(1);
  91. for (int i = -width/2; i < width/2 - 1; i += 5) {
  92. for (int j = -height/2; j < height/2 - 1; j += 5) {
  93. fill(random(100, 255), random(20, 40));
  94. rect(random(i - 5, i), random(j - 5, j), random(1, 2), random(1 ,2));
  95. }
  96. }
  97. for (int i = 0; i < 15; i++) {
  98. fill(random(0, 255), 255);
  99. rect(random(-width, width/2), random(-height, height/2), 2, 2);
  100. }
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement