-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
86 lines (83 loc) · 2.62 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Boids Simulation</title>
<style>
body {
margin: 0;
overflow: hidden;
}
#boidsCanvas {
position: absolute;
top: 0;
left: 0;
}
.slider-container{
position: absolute;
left: 10px;
top: 10px;
}
</style>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body>
<canvas id="boidsCanvas"></canvas>
<div class="slider-container">
<div class="slider">
<label for="maxSpeed">Max Speed:</label>
<input type="range" id="maxSpeed" min="1" max="10" value="5" step="0.1" class="rounded-lg cursor-pointer">
</div>
<div class="slider">
<label for="minSpeed">Min Speed:</label>
<input type="range" id="minSpeed" min="1" max="10" value="2" step="0.1">
</div>
<div class="slider">
<label for="avoidFactor">Avoid Factor:</label>
<input type="range" id="avoidFactor" min="0" max="1" value="0.05" step="0.01">
</div>
<div class="slider">
<label for="matchingFactor">Matching Factor:</label>
<input type="range" id="matchingFactor" min="0" max="1" value="0.05" step="0.01">
</div>
<div class="slider">
<label for="centeringFactor">Centering Factor:</label>
<input type="range" id="centeringFactor" min="0" max="0.1" value="0.005" step="0.001">
</div>
<div class="slider">
<label for="turnFactor">Turn Factor:</label>
<input type="range" id="turnFactor" min="0" max="1" value="0.2" step="0.01">
</div>
</div>
<script src="boids.js"></script>
<script>
// Get reference to the slider and listen for changes
const maxSpeedSlider = document.getElementById('maxSpeed');
const minSpeedSlider = document.getElementById('minSpeed');
const avoidFactorSlider = document.getElementById('avoidFactor');
const matchingFactorSlider = document.getElementById('matchingFactor');
const centeringFactorSlider = document.getElementById('centeringFactor');
const turnFactorSlider = document.getElementById('turnFactor');
// Update the parameters based on slider input
maxSpeedSlider.oninput = () => {
maxSpeed = parseFloat(maxSpeedSlider.value);
};
minSpeedSlider.oninput = () => {
minSpeed = parseFloat(minSpeedSlider.value);
};
avoidFactorSlider.oninput = () => {
avoidFactor = parseFloat(avoidFactorSlider.value);
};
matchingFactorSlider.oninput = () => {
matchingFactor = parseFloat(matchingFactorSlider.value);
};
centeringFactorSlider.oninput = () => {
centeringFactor = parseFloat(centeringFactorSlider.value);
};
turnFactorSlider.oninput = () => {
turnFactor = parseFloat(turnFactorSlider.value);
};
</script>
</body>
</html>