Advertisement
Guest User

Untitled

a guest
Jan 17th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.60 KB | None | 0 0
  1. /*float xoff;
  2.  
  3. void setup() {
  4.  
  5. size(600, 600, P3D);
  6. background(0);
  7. }
  8.  
  9. void draw() {
  10. background(0);
  11. xoff = xoff + .01;
  12. float n = noise(xoff) * width;
  13. noStroke();
  14. directionalLight(n+255, 255-n+255, 126, 0, 0, -1);
  15. for (int i=0; i<20; i++) {
  16. translate(width/2, height/2, -height/2);
  17. for (int j=0; j<20; j++) {
  18. rotateX(frameCount/200.0);
  19. rotateY(frameCount/100.0);
  20.  
  21. box(200);
  22. }
  23. }
  24. }*/
  25. float taille = 5;
  26. float x = 100;
  27. float y = 80;
  28. float xoff;
  29. PVector[][] globe;
  30. int total = 15;
  31. float doff=0;
  32.  
  33. //PGraphics ciel = new PGraphics();
  34.  
  35. void setup() {
  36. size(1200, 1200, P3D);
  37. //ciel = createGraphics(width,height);
  38. background(27, 11, 61);
  39. frameRate(30);
  40.  
  41.  
  42. globe = new PVector[total+1][total+1];
  43. }
  44. float nombreEtoile;
  45. void draw() {
  46. //ciel.beginDraw();
  47. float bigEtoile = random(500);
  48. if (nombreEtoile <500) {
  49. fill(255, 255, 255);
  50. ellipse(random(width), random(height), random(5), random(7));
  51. nombreEtoile = nombreEtoile + 0.7 ;
  52. }
  53. //ciel.endDraw();
  54. if (nombreEtoile>490) {
  55. //fill(255);
  56. //xoff = xoff +.01;
  57. //float n = noise(xoff) * width;
  58. //noStroke();
  59. //directionalLight(n+255, 255-n+255, 126, 0, 0, -1);
  60. //for (int i=0; i<20; i++) {
  61.  
  62. /* fill(0, 0, 0, 10);
  63. rect(0, 0, width, height);
  64. if (int(random(30))==int(random(30))) {
  65. eclair(int(random(5)+5), random(width), 0, 10);
  66. }*/
  67. /*translate(width/2, height/2, -height/2);
  68. for (int j=0; j<20; j+=20) {
  69. rotateX(frameCount/200.0);
  70. rotateY(frameCount/100.0);
  71. sphere(taille);
  72. }*/
  73. fill(0, 0, 0, 10);
  74. rect(0, 0, width, height);
  75. if (int(random(30))==int(random(30))) {
  76. eclair(int(random(5)+5), random(width), 0, 10);
  77. }
  78. fill(255, 255, 255);
  79. ellipse(random(width), random(height), random(5), random(7));
  80. nombreEtoile = nombreEtoile +0.5 ;
  81. }
  82.  
  83. if (nombreEtoile>800) {
  84. background(0);
  85. fill(255, 255, 255);
  86. ellipse(random(width), random(height), random(5), random(7));
  87. nombreEtoile = nombreEtoile + 0.5 ;
  88. doff+=0.01;
  89. translate(width/2, height/2, -width/2);
  90. noStroke();
  91. lights();
  92. /*rotateX(map(mouseY, 0, height, -PI, PI));
  93. rotateY(map(mouseX, 0, width, -PI, PI));*/
  94.  
  95. //rotateX(PI/3);
  96. //rotateY(PI/3);
  97.  
  98. fill(50, 50, 50, 200);
  99. voule(0, 0, 250+noise(doff)*50);
  100.  
  101.  
  102. fill(50, 50, 50, 200);
  103. voule(220, 10, 50+noise(doff)*50);
  104.  
  105. fill(50, 50, 50, 200);
  106. voule(-20, -0, 200+noise(doff)*50);
  107.  
  108. fill(0, 0, 0, 10);
  109. rect(0, 0, width, height);
  110. if (int(random(30))==int(random(30))) {
  111. eclair2(int(random(5)+5), random(-150, 150), random(-150, 150), 10);
  112. }
  113. } else if (nombreEtoile>1000) {
  114. }
  115.  
  116. taille = taille + 1;
  117.  
  118. if (taille > 100) {
  119. taille = 100+noise(doff)*50;
  120. }
  121. }
  122.  
  123. void voule(int cx, int cy, float cr ) {
  124. translate(cx, cy);
  125. float xoff=0.01;
  126. float r = cr;
  127. for (int i = 0; i < total+1; i++) {
  128.  
  129. float lat = map(i, 0, total, 0, PI);
  130. for (int j = 0; j < total+1; j++) {
  131. xoff+=0.5;
  132. float lon = map(j, 0, total, 0, TWO_PI);
  133. float x = (r+noise(xoff)*100) * sin(lat) * cos(lon);
  134. float y = (r+noise(xoff)*100) * sin(lat) * sin(lon);
  135. float z = (r+noise(xoff)*100) * cos(lat);
  136. globe[i][j] = new PVector(x, y, z);
  137. }
  138. }
  139.  
  140. for (int i = 0; i < total; i++) {
  141. float hu = map(i, 0, total, 0, 255*6);
  142. noStroke();
  143. strokeWeight(1);
  144. beginShape(TRIANGLE_STRIP);
  145. for (int j = 0; j < total+1; j++) {
  146. PVector v1 = globe[i][j];
  147. vertex(v1.x, v1.y, v1.z);
  148. PVector v2 = globe[i+1][j];
  149. vertex(v2.x, v2.y, v2.z);
  150. }
  151. endShape();
  152. }
  153. }
  154. void eclair(int lng, float cx, float cy, float cs) {
  155. pushMatrix();
  156. float x=cx;
  157. float y=cy;
  158. float s=cs;
  159. for (int i=0; i<lng; i++) {
  160. float vx = random(-50, 50);
  161. float vy = random(30, 200);
  162. s=s* 0.8;
  163. strokeWeight(s);
  164. stroke(255);
  165.  
  166. line(x, y, x+vx, y+vy);
  167. if (int(random(5))==int(random(5))) {
  168. pushMatrix();
  169. eclair(int(random(5)), x, y, s);
  170. popMatrix();
  171. }
  172. x=x+vx;
  173. y=y+vy;
  174. }
  175. popMatrix();
  176. }
  177.  
  178. void eclair2(int lng, float cx, float cy, float cs) {
  179. pushMatrix();
  180. float x=cx;
  181. float y=cy;
  182. float s=cs;
  183. for (int i=0; i<lng; i++) {
  184. float vx = random(-150, 150);
  185. float vy = random(-150, 150);
  186. s=s* 0.8;
  187. strokeWeight(s);
  188. stroke(255);
  189.  
  190. line(x, y, x+vx, y+vy);
  191. if (int(random(5))==int(random(5))) {
  192. pushMatrix();
  193. eclair(int(random(5)), x, y, s);
  194. popMatrix();
  195. }
  196. x=x+vx;
  197. y=y+vy;
  198. }
  199. popMatrix();
  200. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement