From d250c21876b4c8bfa55e76b0e155185c74001f89 Mon Sep 17 00:00:00 2001 From: Siddhant J Date: Wed, 1 Nov 2023 22:23:12 +0530 Subject: [PATCH] code update --- animations/moveAnimation.js | 16 ---------------- index.html | 10 +++++++--- sorting_algo/bubbleSort.js | 17 +++++++++++++++++ style.css | 6 +++++- 4 files changed, 29 insertions(+), 20 deletions(-) delete mode 100644 animations/moveAnimation.js diff --git a/animations/moveAnimation.js b/animations/moveAnimation.js deleted file mode 100644 index 9607945..0000000 --- a/animations/moveAnimation.js +++ /dev/null @@ -1,16 +0,0 @@ -function animate(moves){ - if(moves.length==0){return;} - - const move=moves.shift(); //i and j contains i-1 and i. - const [i,j] = move.indices; - if(move.type == "swap"){ - [array[i],array[j]] = [array[j],array[i]]; - } - - playNote(200+array[i]*500); //linear interpolation function. - playNote(200+array[j]*500); - showBars(move); - setTimeout(function(){ - animate(moves); - },50); -}; diff --git a/index.html b/index.html index 40fa762..db0e6d2 100644 --- a/index.html +++ b/index.html @@ -16,14 +16,18 @@

Easy to visualize and understand the sorting Algorithms with Sound Effects!<

-
+
-
+ + + + +

+ - \ No newline at end of file diff --git a/sorting_algo/bubbleSort.js b/sorting_algo/bubbleSort.js index 873a4b4..c094a3b 100644 --- a/sorting_algo/bubbleSort.js +++ b/sorting_algo/bubbleSort.js @@ -15,3 +15,20 @@ function bubbleSort(array){ } } + +function animate(moves){ + if(moves.length==0){return;} + + const move=moves.shift(); //i and j contains i-1 and i. + const [i,j] = move.indices; + if(move.type == "swap"){ + [array[i],array[j]] = [array[j],array[i]]; + } + + playNote(200+array[i]*500); //linear interpolation function. + playNote(200+array[j]*500); + showBars(move); + setTimeout(function(){ + animate(moves); + },50); +}; diff --git a/style.css b/style.css index bd693e4..c352cd8 100644 --- a/style.css +++ b/style.css @@ -23,6 +23,10 @@ body { align-items: flex-end; } +.algos{ + display: flex; +} + .bar{ width:10px; background-color: #fefeff;; @@ -38,7 +42,7 @@ body { border: none; display: block; text-align: center; - margin: 20px; + margin:20px; cursor: pointer; text-transform: uppercase; outline: none;