Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class cube {
- float x, y, z;
- float Boff, Goff, Roff;
- float a=random(-PI, PI);
- float d=random(500);
- //color c;
- float redValue=255;
- float greenValue=0;
- float blueValue=0;
- cube() {
- //this.generate(this.c);
- this.generate();
- }
- //void generate(color c) {
- void generate() {
- /* this.Boff = random(255);
- this.Goff = random(255);
- this.Roff = random(255);
- */
- //this.c=c;
- this.x = random(width);
- this.y=random(height);
- this.z=random(150);
- }
- void draw() {
- pushMatrix();
- fill(0,0,0,0);
- //stroke(noise(Roff)*100+150, noise(Goff)*100+152, noise(Boff)*200+50);
- stroke(redValue,greenValue,blueValue);
- translate(this.x, this.y, -(this.z)- sin(this.a)*500);
- rotateY(frameCount/20.0);
- rotateX(frameCount/20.0);
- box(d);
- popMatrix();
- }
- void update() {
- this.a=this.a+0.5;
- this.Boff = this.Boff + 0.1;
- this.Goff = this.Goff + 0.1;
- this.Roff = this.Roff + 0.1;
- if ( greenValue<255 && redValue==255 && blueValue==0) {
- greenValue++;
- }
- //go from yellow to pure green
- if (greenValue == 255 && redValue>0) {
- //redToGreen = false;
- redValue--;
- }
- //go from green to cyan/bluish-green
- if (redValue==0 && greenValue==255 && blueValue<255) {
- blueValue++;
- }
- //go from bluish-green to blue
- if (blueValue==255 && greenValue>0) {
- greenValue--;
- }
- // go from blue to violet
- if (redValue < 255 && greenValue==0 && blueValue==255) {
- redValue++;
- }
- //go from violet to red
- if (redValue == 255 && blueValue>0) {
- blueValue--;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement