Skip to content

Commit

Permalink
Merge pull request #6 from pabloxxy/main
Browse files Browse the repository at this point in the history
Cambios
  • Loading branch information
daranha authored May 8, 2024
2 parents 6a2ac69 + f28a1fd commit 4fa6e4e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
Binary file added .DS_Store
Binary file not shown.
40 changes: 36 additions & 4 deletions NuevoAlgoritmoFractal - Test -/Fractal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -16,6 +15,7 @@ function setup() {
COLOR_FRACTAL = color("#000000");
COLOR_CONTORNO_FRACTAL = color("#000000");


Dibujar();


Expand Down Expand Up @@ -71,7 +71,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
Expand Down Expand Up @@ -221,3 +224,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.
}
}
1 change: 1 addition & 0 deletions NuevoAlgoritmoFractal - Test -/indexFractal.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Fractal test</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.6.0/p5.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/addons/p5.sound.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
Expand Down

0 comments on commit 4fa6e4e

Please sign in to comment.