Advertisement
ahorsewithnoname

Animación inicial

May 9th, 2021
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 7.21 KB | None | 0 0
  1. float size = 1;
  2. int etapa = 0;
  3. int cont = 0;
  4. int contarmenu = 0;
  5.  
  6. void setup(){
  7.   size(400,400);
  8.   textAlign(CENTER,CENTER);
  9. }
  10.  
  11. void draw(){
  12.   animacion();
  13. }
  14.  
  15. void animacion(){
  16.     if(etapa == 0){
  17.     fill(204,255,255);
  18.     noStroke();
  19.     rect(0,0,width,height);
  20.     stroke(0);
  21.     textAlign(CENTER,CENTER);
  22.     fill(0);
  23.     textSize(size);
  24.    
  25.     text("Fractals, multiplication \ntables and light rays:\na Mandelbrot's tale",200,200);
  26.     if(size < 30) size+=0.5;
  27.     if(size == 30){
  28.       etapa = 1;
  29.       delay(1000);
  30.     }
  31.   }
  32.   if(etapa == 1){
  33.     fill(255,15);
  34.     noStroke();
  35.     rect(0,0,width,height);
  36.     stroke(0);
  37.     cont += 1;
  38.     if(cont == 130){
  39.       etapa = 2;
  40.       //delay(1000);
  41.     }
  42.   }
  43.   if(etapa == 2){
  44.     fill(204,255,255);
  45.     noStroke();
  46.     rect(0,0,width,height);
  47.     stroke(0);
  48.     fill(0);
  49.     textSize(30);
  50.     text("¿Qué es un fractal?",width/2,50);
  51.     textSize(10);
  52.     text("Un fractal es un objeto geométrico cuya estructura básica,\nfragmentada o aparentemente irregular,se repite\n a diferentes escalas.\n\nEl propio término fue acuñado por\nBenoît Mandelbrot, cuyo fractal\nveremos en este programa",width/2,170);
  53.     textSize(12);
  54.     text("En el caso del Conjunto de Mandelbrot,\nse define fácilmente con una fórmula:\nz(n-1) = z(n)² + C,\ndonde C es el número complejo que queremos conocer\nsi pertenece al conjunto o no.",width/2,300);
  55.     textSize(9);
  56.     text("(Pulsa cualquier tecla para continuar)",width/2,390);
  57.     if(contarmenu == 1){
  58.       background(204,255,255);
  59.       textSize(12);
  60.       text("Existen infinitos conjuntos de Mandelbrot\ndependiendo del exponente que uses a la hora de calcularlo.\nAunque el general es con exponente 2,\nse puede generalizar la fórmula.",width/2,height/4);
  61.       textSize(13);
  62.       text("Si buscas en Google podrás encontrar fácilmente\nimágenes de cualquier conjunto general\n de Mandelbrot.",width/2,250);
  63.       textSize(9);
  64.       text("(Pulsa cualquier tecla para continuar)",width/2,390);
  65.     }
  66.     if(contarmenu == 2){
  67.       etapa = 3;
  68.       contarmenu = 0;
  69.       delay(200);
  70.      
  71.     }
  72.   }
  73.   if(etapa == 3){
  74.     fill(204,255,255);
  75.     noStroke();
  76.     rect(0,0,width,height);
  77.     stroke(0);
  78.     fill(0);
  79.     textSize(30);
  80.     text("¿Qué son las tablas\nde multiplicar?",width/2,100);
  81.     textSize(13);
  82.     text("Es broma...\nimagino que a estas las conocerás.\nPero, ¿alguna vez te has preguntado\nqué pasaría si las representáramos\ngráficamente?",width/2,230);
  83.     textSize(9);
  84.     text("(Pulsa cualquier tecla para continuar)",width/2,390);
  85.     if(contarmenu == 1){
  86.       background(204,255,255);
  87.       textSize(20);
  88.       text("Para ello, dividiremos en varias partes\niguales un círculo como este:",width/2,60);
  89.       noFill();
  90.       circle(200,150,80);
  91.       text("Por ejemplo:",width/2,230);
  92.      
  93.       circle(200,300,80);
  94.       fill(0);
  95.       circle(200,260,4);
  96.       circle(200,340,4);
  97.       circle(240,300,4);
  98.       circle(160,300,4);
  99.       textSize(9);
  100.       text("(Pulsa cualquier tecla para continuar)",width/2,390);
  101.     }
  102.     if(contarmenu == 2){
  103.       background(204,255,255);
  104.       textSize(12);
  105.       text("Y luego uniremos cada punto\n con su correspondiente según\nla tabla que elijamos.",width/2,100);
  106.       text("Por ejemplo:\nSi hiciéramos la tabla del 2 con 4 nodos\nel 1 se uniría con el 2,\nel 2 se uniría con el 4,\nel 3 con el 6\n y el 4 con el 8.\n\nAunque solo se divida en 4 nodos,\npodremos calcular dónde caerían el 6 y el 8\npor geometría.",width/2,250);
  107.       textSize(9);
  108.       text("(Pulsa cualquier tecla para continuar)",width/2,390);
  109.     }
  110.     if(contarmenu == 3){
  111.       background(204,255,255);
  112.       textSize(13);
  113.       text("Tranquilo si no estás entendiendo nada...\nPronto lo verás en acción y entenderás todo.",width/2,height/2);
  114.       textSize(9);
  115.       text("(Pulsa cualquier tecla para continuar)",width/2,390);
  116.     }
  117.     if(contarmenu == 4){
  118.       etapa = 4;
  119.       contarmenu = 0;
  120.     }
  121.   }
  122.   if(etapa == 4){
  123.     fill(204,255,255);
  124.     noStroke();
  125.     rect(0,0,width,height);
  126.     stroke(0);
  127.     fill(0);
  128.     textSize(30);
  129.     text("Por último...\nRayos y reflexión.",width/2,80);
  130.     textSize(13);
  131.     text("Como tal vez conozcas si has estudiado\nalgo de física, cuando un rayo incide en\n una superficie se refleja con el mismo\nángulo con el que ha incidido\nrespecto a la normal, tal que así:",width/2,210);
  132.     pushMatrix();
  133.     translate(200,320);
  134.     strokeWeight(2);
  135.     line(-50,0,50,0);
  136.     strokeWeight(1);
  137.     stroke(0,0,255);
  138.     arrow(-30,-40,0,0);
  139.     stroke(255,0,0);
  140.     arrow(0,0,30,-40);
  141.     stroke(0);
  142.    
  143.     popMatrix();
  144.     textSize(9);
  145.     text("(Pulsa cualquier tecla para continuar)",width/2,390);
  146.     if(contarmenu == 1){
  147.       background(204,255,255);
  148.       textSize(13);
  149.       text("Pues bien, resulta sorprendente\nlo que pasa si lanzamos varios rayos\nen una superficie circular desde el centro...",width/2,200);
  150.       textSize(9);
  151.       text("(Pulsa cualquier tecla para continuar)",width/2,390);
  152.     }
  153.     if(contarmenu == 2){
  154.       background(204,255,255);
  155.       textSize(17);
  156.       text("Aunque parezca increíble,\nla figura que forman coincide\ncon el nodo principal\ndel conjunto de Mandelbrot!", 200,200);
  157.       textSize(9);
  158.       text("(Pulsa cualquier tecla para continuar)",width/2,390);
  159.     }
  160.     if(contarmenu == 3){
  161.       background(204,255,255);
  162.       textSize(20);
  163.       textAlign(CENTER,CENTER);
  164.       text("¿Dónde está la gracia\no la relación aquí?",200, 60);
  165.       textAlign(LEFT,CENTER);
  166.       textSize(14);
  167.       text("-No solo el conjunto de Mandelbrot con exponente 2\naparece en la tabla del 2, si no que TODOS\nlos conjuntos de Mandelbrot aparecen.\nEs decir, si buscas el conjunto de Mandelbrot\ncon exponente 3 y haces la tabla del 3\ncon el modo 1, verás que el módulo central coincide.\n\n-Aparecen, así, relacionados, tres\nfenómenos de ramas diferentes, como son\nlos fractales y las tablas de multiplicar (matemáticas)\ny la reflexión (óptica física).",20,230);
  168.       textAlign(CENTER,CENTER);
  169.       textSize(9);
  170.       text("(Pulsa cualquier tecla para continuar)",width/2,390);
  171.     }
  172.     if(contarmenu == 4){
  173.       background(204,255,255);
  174.       textSize(20);
  175.       textAlign(CENTER,CENTER);
  176.       text("A partir de aquí, podrás\nexperimentar por tí mismo...",200, 60);
  177.       textAlign(LEFT,CENTER);
  178.       textSize(14);
  179.       text("-En el modo 1 podrás crear tus propias\ntablas de multiplicar y experimentar con ellas.\n\n-En el modo 2 podrás ver cómo cambian las tablas\nen forma de animación.\n\n-En el modo 3 podrás ver, de forma colorida,\nla reflexión de rayos de luz en una superficie circular.\n\n-En el modo 4 podrás calificar el trabajo.",20,230);
  180.       textAlign(CENTER,CENTER);
  181.       textSize(9);
  182.       text("(Pulsa cualquier tecla para continuar)",width/2,390);
  183.     }
  184.     if(contarmenu == 5){
  185.     }
  186.   }
  187.   println(etapa);
  188. }
  189.  
  190. void keyPressed(){
  191.   contarmenu += 1;
  192. }
  193.  
  194. void arrow(float x1, float y1, float x2, float y2) {
  195.   line(x1, y1, x2, y2);
  196.   pushMatrix();
  197.   translate(x2, y2);
  198.   float a = atan2(x1-x2, y2-y1);
  199.   rotate(a);
  200.   line(0, 0, -3, -3);
  201.   line(0, 0, 3, -3);
  202.   popMatrix();
  203. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement