-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
241 lines (224 loc) · 9.51 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/top-menu.css">
<link rel="stylesheet" href="css/modals.css">
<link rel="icon" type="image/png" href="img/arrow.png">
<title>Active Matter Simulation</title>
</head>
<style>
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;700&display=swap');
body {
margin: 0;
padding: 0;
background: #000;
overflow: hidden;
font-family: "Montserrat", serif;
}
/* position the content above the canvas */
.content-container {
z-index: 1;
}
/* make the canvas fill the entire screen */
#canvas {
position: absolute;
z-index: 0;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
</style>
<body>
<canvas id="canvas"></canvas>
<div class="content-container">
<!-- top left menu buttons -->
<div id="top-menu">
<div id="options-icon" class="top-menu-items"><i><img src="img/plus.png"></i></div>
<div id="status-icon" class="top-menu-items"><i><img src="img/options.png"></i></div>
<div id="focus-icon" class="top-menu-items"><i><img src="img/focus.png"></i></div>
</div>
<!-- pause info -->
<div id="pause-info">
<h2 id="pause-info-title">Active Matter Simulation</h2>
<p id="pause-info-text">Click anywhere to start the simulation.</p>
<p id="pause-info-author">by Benjamin Iriarte Crom <a href="https://github.com/ben-tiki">github.com/ben-tiki</a>
</p>
</div>
<!-- key bindings -->
<div id="key-bindings">
<h2 id="key-bindings-title">Key Bindings</h2>
<p id="key-bindings-text">
<span class="key-binding">r</span> - Reset the simulation<br>
<span class="key-binding">p</span> - Pause the simulation<br>
<span class="key-binding">f</span> - Focus on boid<br>
<span class="key-binding">a</span> - Add a new boid<br>
<span class="key-binding">d</span> - Delete a boid<br>
<span class="key-binding">+</span> - Speed up the simulation<br>
<span class="key-binding">-</span> - Slow down the simulation<br>
<span class="key-binding">k</span> - Up interaction radius<br>
<span class="key-binding">j</span> - Down interaction radius<br>
<span class="key-binding">↑</span> - Increase the boid size<br>
<span class="key-binding">↓</span> - Decrease the boid size<br>
<span class="key-binding">→</span> - Focus on next boid<br>
<span class="key-binding">←</span> - Focuson previous boid<br>
<span class="key-binding">m</span> - Up noise<br>
<span class="key-binding">n</span> - Down noise<br>
<span class="key-binding">i</span> - Show/hide interaction radius<br>
<span class="key-binding">esc</span> - Close the menu<br>
<span class="key-binding">s</span> - Save the current frame to image<br>
</p>
</div>
<!-- main options -->
<div class="modal-container" id="options-modal">
<div class="modal-content">
<h1 id="control-keybind">Controls <span class="key-binding">+</span></h1>
<hr id="horizonal-control-line">
<!-- number of boids -->
<div class="main-modal-wrapper">
<div class="main-modal-title">Number of Boids</div>
<div class="main-modal-content">
<input type="range" min="1" max="2000" class="slider" id="boids-number">
<p><span id="boids-number-value"></span></p>
</div>
</div>
<!-- boids velocity -->
<div class="main-modal-wrapper">
<div class="main-modal-title">Boids Velocity</div>
<div class="main-modal-content">
<input type="range" min="0" max="20" step="0.5" class="slider" id="boids-velocity">
<p><span id="boids-velocity-value"></span></p>
</div>
</div>
<!-- boid interaction radius -->
<div class="main-modal-wrapper">
<div class="main-modal-title">Interaction Radius</div>
<div class="main-modal-content">
<input type="range" min="0" max="250" class="slider" id="boids-interaction-radius">
<p><span id="boids-interaction-radius-value"></span></p>
</div>
</div>
<!-- boid random movement -->
<div class="main-modal-wrapper">
<div class="main-modal-title">Random Movement</div>
<div class="main-modal-content">
<input type="range" min="0" max="10" step="0.25" class="slider" id="boids-noise">
<p><span id="boids-noise-value"></span></p>
</div>
</div>
<!-- boid si<e -->
<div class="main-modal-wrapper">
<div class="main-modal-title">Boids Size</div>
<div class="main-modal-content">
<input type="range" min="0" max="40" class="slider" id="boids-size">
<p><span id="boids-size-value"></span></p>
</div>
</div>
<!-- wall behaviour -->
<div id="main-menu-buttons">
<div class="main-modal-wrapper">
<div class="main-modal-title">Wall Collision</div>
<div class="main-modal-content">
<button id="boids-bounce">Bounce</button>
<button id="boids-travel">Travel</button>
</div>
</div>
<div id="dropwdown-wrapper">
<!-- color & spawn options -->
<div class="main-modal-wrapper">
<div class="main-modal-title">Color & Spawn Options</div>
<div class="main-modal-content">
<select name="color-options" id="color-options">
<option value="none">Normal</option>
<option value="center">Center</option>
<option value="quadrant">Quadrant</option>
<option value="neighbors">Neighbors</option>
<option value="direction">Direction</option>
<option value="position">Position</option>
<option value="time">Time</option>
<option value="mouse">Mouse</option>
</select>
<select name="spawn-options" id="spawn-options">
<option class="option" value="random">Random</option>
<option class="option" value="circle">Circle</option>
<option class="option" value="grid">Grid</option>
<option class="option" value="oval">Oval</option>
<option class="option" value="rhomboid">Rhomboid</option>
<option class="option" value="spirograph">Spirograph</option>
<option class="option" value="spiral">Spiral</option>
<option class="option" value="letter">Letter</option>
</select>
</div>
</div>
</div>
<!-- trail options -->
<div class="main-modal-wrapper">
<div class="main-modal-title">Trail Options</div>
<div class="main-modal-content">
<button id="trail-none">None</button>
<button id="trail-soft">Soft</button>
<button id="trail-hard">Hard</button>
</div>
</div>
<!-- seek mouse -->
<div class="main-modal-wrapper">
<div class="main-modal-title">Mouse Seeking</div>
<div class="main-modal-content">
<button id="mouse-follow">Follow</button>
<button id="mouse-ignore">Ignore</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- status modal -->
<div class="modal-container" id="status-modal">
<div class="modal-content">
<h1>Status</h1>
<hr>
<h3 id="number-boids-display"></h3>
<h3 id="boid-size-display"></h3>
<h3 id="boid-velocity-display"></h3>
<h3 id="interaction-radius-display"></h3>
<h3 id="boid-noise-display"></h3>
</div>
</div>
<!-- focus modal -->
<div class="modal-container" id="focus-modal">
<div class="modal-content">
<h1 id="focus-boid-display"></h1>
<hr>
<h3 id="boid-position-display"></h3>
<h3 id="boid-neighbors-display"></h3>
<h3 id="boid-angle-display"></h3>
<h3 id="boid-quadrant-display"></h3>
</div>
</div>
<!-- start boids at letter form -->
<label style="visibility: hidden";>Type some text: <input id="input" value="B E N - T I K I"></label>
</div>
</body>
<script>
// -------------------------- CANVAS ------------------------------
// load the canvas
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
// makes the canvas fullscreen
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
// add event listener for canvas resizing
window.addEventListener("resize", function () {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
}
);
</script>
<script src="js/inputEvents.js"></script>
<script src="js/modals.js"></script>
<script src="js/helpers.js"></script>
<script src="js/activematter.js"></script>
<script src="js/menu.js"></script>
</html>