Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. caja vector [] = new caja [20];
  2.  
  3. float a;
  4.  
  5. void setup(){
  6. size(500,500,P3D);
  7. inicializacion();
  8. }
  9.  
  10. void inicializacion(){
  11. for(int i=0;i<vector.length;i++){
  12. vector[i]=new caja(random(height));
  13. }
  14. }
  15.  
  16. void draw(){
  17. if(keyPressed == true){
  18. inicializacion();
  19. }
  20.  
  21. if(mousePressed == true){
  22. for(int j=0;j<vector.length;j++){
  23. // inicia ordenamiento B
  24. for(int i=0;i<vector.length-1;i++){
  25. if(vector[i].tam<vector[i+1].tam){
  26. float aux=vector[i].tam;
  27. vector[i].tam=vector[i+1].tam;
  28. vector[i+1].tam=aux;
  29. }
  30. }
  31. }
  32. } else{mostrar(); }
  33. }
  34.  
  35. void mostrar(){
  36. background(0);
  37. for(int i=0;i<vector.length;i++){
  38. pushMatrix();
  39. lights();
  40. translate(map(i,0,vector.length,width/vector.length,width),height/2);
  41. strokeWeight(1);
  42. fill(vector[i].c);
  43. rotateX(a);
  44. rotateY(a);
  45. rotateZ(a);
  46. stroke(vector[i].c);
  47. box(map(vector[i].tam,0,height,0,height/vector.length));
  48. a=a+0.001;
  49. popMatrix();
  50.  
  51. }
  52.  
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement