From 3af2cff271dc7697b11c05ae8c94d5d43855a684 Mon Sep 17 00:00:00 2001 From: pabloxxy <76660927+pabloxxy@users.noreply.github.com> Date: Mon, 6 May 2024 12:02:45 -0600 Subject: [PATCH 1/2] =?UTF-8?q?agregu=C3=A9=20p5sound=20al=20index?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 0 -> 6148 bytes NuevoAlgoritmoFractal - Test -/indexFractal.html | 1 + 2 files changed, 1 insertion(+) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..47f9549d0d2ce20867cf57164be0ad6f48fd13e4 GIT binary patch literal 6148 zcmeHKy-vem3_L@JN-Q0j(Dwozc!Q6sW$XeEKxq*|N)?IH&e?eFo_~;tLe-4{Y{}on z&e>6Jh+_aU+iz}x34k$O5ubVtP4BA@>>@Hkq_anhJ2ZGDz7NC5$mmn5R5NlxP$P7)ql<1`rD~5PE^CfsSuygcs zNGu-`PnOtF#GcOn#psagm}e@G3iK7Y^l+l{e?dR7|M!bBN(EAZKc#?-<`453Unyqm y;N^7I7WxzY%g8l44;#fq8^sKC6kmVi6}{&D8rV5nIrCOd%pU>OB`p>B4F!%{OB;3o literal 0 HcmV?d00001 diff --git a/NuevoAlgoritmoFractal - Test -/indexFractal.html b/NuevoAlgoritmoFractal - Test -/indexFractal.html index e778796..fecff96 100644 --- a/NuevoAlgoritmoFractal - Test -/indexFractal.html +++ b/NuevoAlgoritmoFractal - Test -/indexFractal.html @@ -6,6 +6,7 @@ Fractal test + From f28a1fd1a83190d6ad30e29b3c30b604bfe35da9 Mon Sep 17 00:00:00 2001 From: pabloxxy <76660927+pabloxxy@users.noreply.github.com> Date: Tue, 7 May 2024 12:33:06 -0600 Subject: [PATCH 2/2] =?UTF-8?q?a=C3=B1ad=C3=AD=20una=20funci=C3=B3n=20para?= =?UTF-8?q?=20crear=20losm=20osciladores?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NuevoAlgoritmoFractal - Test -/Fractal.js | 40 ++++++++++++++++++++--- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/NuevoAlgoritmoFractal - Test -/Fractal.js b/NuevoAlgoritmoFractal - Test -/Fractal.js index 046677e..30dec7d 100644 --- a/NuevoAlgoritmoFractal - Test -/Fractal.js +++ b/NuevoAlgoritmoFractal - Test -/Fractal.js @@ -3,10 +3,9 @@ let PROPORCION = 0.5; let ZOOM = 100; let ITERACIONES = 5; let NUMERO_VERTICES = 4; -let COLOR_BACKGROUND; -let COLOR_FRACTAL; -let COLOR_CONTORNO_FRACTAL; -let IMAGEN; +let COLOR_BACKGROUND, COLOR_FRACTAL, COLOR_CONTORNO_FRACTAL, IMAGEN; + + function setup() { createCanvas(windowWidth, windowHeight); @@ -16,6 +15,7 @@ function setup() { COLOR_FRACTAL = color("#000000"); COLOR_CONTORNO_FRACTAL = color("#000000"); + Dibujar(); @@ -70,7 +70,10 @@ function Dibujar() { rotate(PI / NUMERO_VERTICES) DibujarFractal(0, 0, createVector(0, 0), ZOOM, NUMERO_VERTICES, ITERACIONES); pop(); + } + + /* DibujarFractal: Dibuja un fractal de poligonos con parametros: --> centro: (centroX, centroY), la posicion donde se empieza a dibujar el fractal @@ -220,3 +223,32 @@ function DibujarPoligono(centroX, centroY, radio, numVertices, iteraciones) { } endShape(CLOSE); } + + +//Función para que el oscilador suene como un metrónomo. +function startMetronome(){ + //Crear la lista con osciladores + let oscillators = []; + let isPlaying = []; + + for (let i = 0; i <= ITERACIONES; i++) { + let osc = new p5.Oscillator(); + osc.setType('sine'); + osc.freq(200*i); + osc.amp(0.5); + oscillators.push(osc); + isPlaying.push(false); + } + //Hacer que suenen como metrónomo + for (let i = 0; i <= ITERACIONES; i++) { + setInterval(function() { + if (isPlaying[i]) { + oscillators[i].stop(); + isPlaying[i] = false; + } else { + oscillators[i].start(); + isPlaying[i] = true; + } + }, floor(1000/(i+1))); //El i-ésimo oscilador sonará cada 1/(i+1) segundos. + } +} \ No newline at end of file