Advertisement
Guest User

Untitled

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