Advertisement
Guest User

Untitled

a guest
Jan 18th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. class boule {
  2. float x, y, z;
  3. float Boff, Goff, Roff;
  4. float a=random(-PI, PI);
  5. float d=random(250);
  6. //color c;
  7.  
  8. float redValue=255;
  9. float greenValue=0;
  10. float blueValue=0;
  11.  
  12. boolean visible = false;
  13.  
  14. boolean isCube = false;
  15. boule() {
  16. //this.generate(this.c);
  17. this.generate();
  18. float r = random(1);
  19. if (r>0.5) {
  20.  
  21. isCube = true;
  22. } else {
  23. isCube=false;
  24. }
  25. }
  26.  
  27. //void generate(color c) {
  28. void generate() {
  29. /* this.Boff = random(255);
  30. this.Goff = random(255);
  31. this.Roff = random(255);
  32. */
  33.  
  34.  
  35.  
  36. //this.c=c;
  37. this.x = random(width);
  38. this.y=random(height);
  39. this.z=random(500);
  40. }
  41.  
  42. void draw() {
  43. pushMatrix();
  44. fill(0, 0, 0);
  45. //stroke(noise(Roff)*100+150, noise(Goff)*100+152, noise(Boff)*200+50);
  46. stroke(redValue, greenValue, blueValue);
  47. translate(this.x, this.y, -(this.z)- sin(this.a)*350);
  48. rotateY(frameCount/15.0);
  49. rotateX(frameCount/15.0);
  50. if (visible) {
  51.  
  52. if (isCube) {
  53. box(d);
  54. } else {
  55. sphere(d);
  56. }
  57. }
  58.  
  59. popMatrix();
  60. }
  61.  
  62. void update() {
  63. this.a=this.a+0.5;
  64. this.Boff = this.Boff + 0.1;
  65. this.Goff = this.Goff + 0.1;
  66. this.Roff = this.Roff + 0.1;
  67. if ( greenValue<255 && redValue==255 && blueValue==0) {
  68. greenValue++;
  69. }
  70.  
  71. //go from yellow to pure green
  72. if (greenValue == 255 && redValue>0) {
  73. //redToGreen = false;
  74. redValue--;
  75. }
  76.  
  77. //go from green to cyan/bluish-green
  78. if (redValue==0 && greenValue==255 && blueValue<255) {
  79.  
  80. blueValue++;
  81. }
  82.  
  83. //go from bluish-green to blue
  84. if (blueValue==255 && greenValue>0) {
  85. greenValue--;
  86. }
  87. // go from blue to violet
  88. if (redValue < 255 && greenValue==0 && blueValue==255) {
  89. redValue++;
  90. }
  91. //go from violet to red
  92. if (redValue == 255 && blueValue>0) {
  93. blueValue--;
  94. }
  95. }
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement