Advertisement
Guest User

Nothing Here

a guest
Nov 13th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.63 KB | None | 0 0
  1. class Structures
  2. {
  3. float r, g, b;
  4. Structures()
  5. {
  6. r=0;
  7. g=233;
  8. b=233;
  9.  
  10. box = createShape();
  11. box.beginShape();
  12. //box.stroke(#FFF758);
  13. //box.strokeWeight(2);
  14. box.vertex(170, 700);
  15. box.vertex(378, 585);
  16. box.vertex(1025, 700);
  17. box.vertex(1025, 1050);
  18. box.vertex(378, 1095);
  19. box.vertex(170, 1020);
  20. //box.vertex(378, 585);
  21. //box.vertex(378, 1095);
  22. //box.quad(, , , );
  23. box.endShape();
  24. shapeMode(CENTER);
  25. }
  26. void render()
  27. {
  28. {
  29. float r=flyer.velocity.x;
  30. // r = map(r,0,width,0,255);
  31. float g = flyer.velocity.y;
  32. // g = map(g,0,height,0,255);
  33. float theta = atan2(g,r)+PI;
  34. println(theta);
  35. colorMode(HSB,TWO_PI,100,100);
  36.  
  37. box.setFill(color(theta,100,80));
  38. shape(box, width/2, height/2, width/3, height/4);
  39. //setFill(random(244));
  40. colorMode(RGB,255,255,255,255);
  41. }
  42. }
  43. }
  44.  
  45. ///////////////////////////
  46. class Flyer1
  47. {
  48. float x, y, vx, vy;
  49. PVector location;
  50. PVector velocity;
  51. PVector acceleration;
  52. float topspeed;
  53. Flyer1()
  54. {
  55. location=new PVector(random(0, width), random(0, height));
  56. velocity=new PVector(0, 0);
  57. topspeed=10;
  58. }
  59.  
  60. void update()
  61. {
  62. PVector direction = new PVector((random(width/2, width)-(width/2)), (random(height/2, height)-(height/2)));
  63. PVector acceleration = PVector.sub(direction, location);
  64. acceleration.setMag(0.2);
  65. velocity.add(acceleration);
  66. velocity.limit(topspeed);
  67. location.add(velocity);
  68. }
  69. void display()
  70. {
  71. stroke(255);
  72. strokeWeight(2);
  73. fill(127);
  74. ellipse(0+location.x, 0+location.y, 48, 48);
  75. }
  76. }
  77. class Flyer
  78. {
  79. float x, y, vx, vy;
  80. PVector location;
  81. PVector velocity;
  82. PVector acceleration;
  83. float topspeed;
  84. Flyer()
  85. {
  86. location=new PVector(random(0, width), random(0, height));
  87. velocity=new PVector(0, 0);
  88. topspeed=10;
  89. }
  90.  
  91. void update()
  92. {
  93. PVector direction = new PVector((random(width/2, width)-(width/2)), (random(height/2, height)-(height/2)));
  94. PVector acceleration = PVector.sub(direction, location);
  95. acceleration.setMag(0.2);
  96. velocity.add(acceleration);
  97. velocity.limit(topspeed);
  98. location.add(velocity);
  99. }
  100. void display()
  101. {
  102. stroke(255);
  103. strokeWeight(2);
  104. fill(127);
  105. ellipse(0+location.x, 0+location.y, 48, 48);
  106. }
  107. }
  108. ///////////////////////////////
  109. class Lines
  110. {
  111. float x, y, vx, vy;
  112.  
  113. Lines()
  114. {
  115. x=0;
  116. y=0;
  117. }
  118. void update()
  119.  
  120. {
  121. x=x+2;
  122. }
  123. void display()
  124. {
  125. pushMatrix();
  126. translate(x, 0);
  127. stroke(a, noise(x*0.01, y*0.01, 12395)*255, noise(x*0.01, y*0.01, 12395)*255);
  128. //stroke(255);
  129. strokeWeight(3);
  130. line(0, 0, 0, height);
  131. popMatrix();
  132. }
  133. }
  134. ///////////////////////////////
  135. //Globals
  136. Lines l;
  137. ArrayList<Lines> lines;
  138. int delay, delayCount, numLines, lineCount;
  139. float freq= 10;
  140. float a = frameCount;
  141. float ang=radians(40);
  142. Flyer flyer;
  143. Flyer1 flyer1;
  144. Structures structure;
  145.  
  146. PShape box;
  147.  
  148.  
  149. Flyer[] flyers = new Flyer[50];
  150. ///////////////////////////////
  151. void setup()
  152. {
  153. fullScreen(P2D);
  154. l = new Lines();
  155. lines= new ArrayList<Lines>();
  156. delay =int(random(0, 90));//limiting variable
  157. delayCount=0;
  158. numLines=int(random(1, 20));//limiting variable
  159. lineCount=0;
  160. structure= new Structures();
  161. flyer=new Flyer();
  162. flyer1=new Flyer1();
  163.  
  164. for(int i = 0; i < flyers.length;i++)
  165. {
  166. flyers[i] = new Flyer();
  167. }
  168. }
  169. void draw()
  170. {
  171. background(0);
  172. flyer.update();
  173. flyer.display();
  174. //flyer1.update();
  175. //flyer1.display();
  176. for(int i = 0; i < flyers.length;i++)
  177. {
  178. flyers[i].update();
  179. flyers[i].display();
  180. }
  181. if (delayCount<delay)
  182. {
  183. delayCount++;
  184. } else
  185. {
  186. if (lineCount<numLines)
  187. {
  188. lineCount++;
  189. lines.add(new Lines());
  190. } else
  191. {
  192. delayCount=0;
  193. lineCount=0;
  194. delay =int(random(0, 90));
  195. numLines=int(random(1, 20));
  196. }
  197. }
  198. //l.update();
  199. //l.display();
  200. //for (int i=0; i< 2*height; i+=1)
  201. //{
  202. // x+=sin(ang)*amp;
  203. // y+=cos(ang)*amp;
  204. // stroke(a, noise(x*0.01, y*0.01, 12395)*255, noise(x*0.01, y*0.01, 12395)*255);
  205. // vertex(frameCount, y);
  206. // if (x>=width)
  207. // {
  208. // x=0;
  209. // }
  210. //}
  211. if (mousePressed)
  212. {
  213. for (int i=0; i<1; i++)
  214. {
  215. lines.add(new Lines());
  216. }
  217. }
  218. for (int i=0; i<lines.size(); )
  219. {
  220. if (lines.get(i).x > width)
  221. {
  222. lines.remove(i);
  223. //println("remove");
  224. } else
  225. {
  226. lines.get(i).update();
  227. lines.get(i).display();
  228. i++;
  229. }
  230. }
  231. structure.render();
  232. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement