Skip to content

Commit 53dc163

Browse files
authored
Merge pull request #6 from DSDmark/test
Test
2 parents 141ad49 + 737c8ef commit 53dc163

4 files changed

Lines changed: 123 additions & 13 deletions

File tree

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
![GitHub last commit](https://img.shields.io/github/last-commit/DSDmark/TodoList)
77
[![pages-build-deployment](https://github.com/DSDmark/TodoList/actions/workflows/pages/pages-build-deployment/badge.svg)](https://github.com/DSDmark/TodoList/actions/workflows/pages/pages-build-deployment)
88

9-
# Your First Application 🤟
10-
## Walcome to Webdev 😊
9+
# BubbleSort-Visualization
1110

1211
<div>
1312

@@ -31,20 +30,20 @@ Once you are done you can close the application in your terminal to quit the ap
3130

3231
---
3332

34-
## Try Out TodoList Demo
33+
## BubbleSort-Visualization
3534

3635
<a href="https://dsdmark.github.io/TodoList/" alt="TodoList Demo">TodoList Demo</a>
3736

3837
</div>
3938

40-
### Todo List
39+
### BubbleSort-Visualization
4140

42-
![Todo List perview](public/images/perview.gif "Todo List")
41+
![BubbleSort-Visualization](public/images/perview.gif "BubbleSort-Visualization")
4342

4443
</div>
4544

4645
> If you have any issues with that Application feel free to let me know!
4746
48-
> If you are more interested, check out the collection of [ **CLIsapplications**](https://github.com/DSDmark/CLIsapplications"CLIsapplications").
47+
> If you are more interested, check out the collection of [ **DSDmark**](https://github.com/DSDmark/BubbleSort-Visualization").
4948
---
5049

assets/js/index.js

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const canvas = document.getElementById('cvs')
2+
const stopButton = document.getElementById('stopbutton')
23
const ctx = canvas.getContext('2d')
34
const CH = (canvas.height = 300)
45
const CW = (canvas.width = 600)
@@ -18,10 +19,14 @@ const BubbleSort = {
1819
ctx.clearRect(0, 0, CH, CW)
1920
const lineSpacing = 10
2021
ctx.lineWidth = 5
22+
<<<<<<< HEAD
23+
for (let j = 1; j < this.seedValue.length; j++) {
24+
=======
2125

2226
for (let j = 0; j < this.seedValue.length; j++) {
27+
>>>>>>> 141ad495338db7854c07ee1ae9ffeeb6ebc6f429
2328
const y = j * lineSpacing
24-
ctx.beginPath()
29+
ctx.beginPath()
2530
ctx.moveTo(y, CH)
2631
ctx.lineTo(y, CH - this.seedValue[j])
2732
ctx.closePath()
@@ -37,14 +42,15 @@ const BubbleSort = {
3742
}
3843
},
3944
update() {
45+
4046
if (this.seedValue[this.j] > this.seedValue[this.j + 1]) {
4147
;[this.seedValue[this.j], this.seedValue[this.j + 1]] = [
4248
this.seedValue[this.j + 1],
4349
this.seedValue[this.j],
4450
]
4551
this.sortedLine = this.seedValue[this.j + 1]
4652
}
47-
if (this.i < this.seedValue.length) {
53+
if (this.i < this.seedValue.length || isClick) {
4854
this.j++
4955
if (this.j >= this.seedValue.length - this.i - 1) {
5056
this.color = 'red'
@@ -53,7 +59,9 @@ const BubbleSort = {
5359
}
5460
} else {
5561
this.isLoop = false
62+
clearInterval()
5663
}
64+
5765
this.draw()
5866
},
5967
startup() {
@@ -63,18 +71,31 @@ const BubbleSort = {
6371
this.seedValue[this.i] = Math.random() * (CH - 0 + 1) + 0
6472
}
6573
this.i = 0
74+
75+
// Hendling Evnets.
6676
},
77+
stopLoop() {
78+
clearInterval();
79+
},
6780
}
6881

6982
// You could use window.requestAnimationFrame as well. but, for simplicity i'm using setInterval.
70-
83+
let cleaer;
84+
stopButton.addEventListener('click',()=>{
85+
// p
86+
// clearInterval(cleaer);
87+
} )
7188
function render() {
7289
BubbleSort.startup()
73-
if (BubbleSort.isLoop) {
74-
setInterval(() => {
90+
if (BubbleSort.isLoop) {
91+
92+
cleaer = setInterval(() => {
7593
BubbleSort.update(BubbleSort.seedValue)
94+
7695
}, BubbleSort.loopSpeed)
77-
}
96+
}else{
97+
console.log("final");
98+
}
7899
}
79100

80101
render() // calling the main functions.

assets/style/style.css

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,31 @@
11
body{
2+
<<<<<<< HEAD
3+
display:grid;
4+
place-items:center;
5+
min-height:100vh;
6+
background:gray;
7+
}
8+
.tab {
9+
display:flex;
10+
width: auto;
11+
height: 300px;
12+
}
13+
.inputField{
14+
display:flex;
15+
align-items:left;
16+
padding:3px;
17+
flex-direction:column;
18+
border: 1px solid #ccc;
19+
background-color: #f1f1f1;
20+
width: auto;
21+
height:auto;
22+
}
23+
=======
224
background-color: gray;
325
display: flex;
426
justify-content: center;
527
align-items: center;
628
min-height: 100vh;
729
overflow: hidden;
8-
}
30+
}
31+
>>>>>>> 141ad495338db7854c07ee1ae9ffeeb6ebc6f429

index.html

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,75 @@
88
<link rel="stylesheet" href="./assets/style/style.css" />
99
</head>
1010
<body>
11+
<<<<<<< HEAD
12+
<div class="tab">
13+
<div class="inputField">
14+
<button class="tablinks" id="stopbutton">Stop Sorting</button> <br />
15+
<label for="sortedlinecolor">
16+
Sorted line color:<br />
17+
<input class="tablinks" id="sortedlinecolor" value="red" /> </label
18+
><br />
19+
<label for="lienescolors">
20+
colors of lines:<br />
21+
<input
22+
class="tablinks"
23+
id="linescolors"
24+
type="text"
25+
value="white"
26+
/> </label
27+
><br />
28+
<label for="sizeoflines">
29+
Size of lines:<br />
30+
<input
31+
class="tablinks"
32+
type="range"
33+
id="sizeoflines"
34+
min="0"
35+
max="100"
36+
value="50"
37+
/>
38+
</label>
39+
<label for="numberoflines">
40+
Number of lines:<br />
41+
<input
42+
class="tablinks"
43+
id="numberoflines"
44+
type="range"
45+
min="0"
46+
max="100"
47+
value="50"
48+
/>
49+
</label>
50+
<label for="sizeofcanvas">
51+
Size of canvas(lenght):<br />
52+
<input
53+
class="tablinks"
54+
id="sizeofcanvas"
55+
type="range"
56+
min="0"
57+
max="100"
58+
value="50"
59+
/> </label
60+
><br />
61+
<label for="sizeofcanvas">
62+
Size of canvas(lenght):<br />
63+
<input
64+
class="tablinks"
65+
id="sizeofcanvas"
66+
type="range"
67+
min="0"
68+
max="100"
69+
value="50"
70+
/> </label
71+
><br />
72+
</div>
73+
<canvas id="cvs"></canvas>
74+
</div>
75+
<!-- The main section when all things will heppening -->
76+
=======
1177
<!-- The main section when all things will heppening -->
1278
<canvas id="cvs"></canvas>
79+
>>>>>>> 141ad495338db7854c07ee1ae9ffeeb6ebc6f429
1380
<script src="./assets/js/index.js"></script>
1481
</body>
1582
</html>

0 commit comments

Comments
 (0)