Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- caja vector [] = new caja [20];
- float a;
- void setup(){
- size(500,500,P3D);
- inicializacion();
- }
- void inicializacion(){
- for(int i=0;i<vector.length;i++){
- vector[i]=new caja(random(height));
- }
- }
- void draw(){
- if(keyPressed == true){
- inicializacion();
- }
- if(mousePressed == true){
- for(int j=0;j<vector.length;j++){
- // inicia ordenamiento B
- for(int i=0;i<vector.length-1;i++){
- if(vector[i].tam<vector[i+1].tam){
- float aux=vector[i].tam;
- vector[i].tam=vector[i+1].tam;
- vector[i+1].tam=aux;
- }
- }
- }
- } else{mostrar(); }
- }
- void mostrar(){
- background(0);
- for(int i=0;i<vector.length;i++){
- pushMatrix();
- lights();
- translate(map(i,0,vector.length,width/vector.length,width),height/2);
- strokeWeight(1);
- fill(vector[i].c);
- rotateX(a);
- rotateY(a);
- rotateZ(a);
- stroke(vector[i].c);
- box(map(vector[i].tam,0,height,0,height/vector.length));
- a=a+0.001;
- popMatrix();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement