-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
322 lines (295 loc) · 16.1 KB
/
Copy pathindex.html
File metadata and controls
322 lines (295 loc) · 16.1 KB
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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
<!DOCTYPE html>
<html lang="en" data-theme="dark">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>Vector Field Simulator</title>
<!-- CSS Stylesheets -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
<!-- App JS Entry Point -->
<script type="module" src="/src/main.js"></script>
<!-- MathJax Configuration and Script -->
<script>
window.MathJax = {
tex: {
inlineMath: [['$','$'], ['\\(','\\)']],
processEscapes: true
},
options: {
enableMenu: false
}
};
</script>
<script defer src="https://cdn.jsdelivr.net/npm/mathjax@4.1.3/tex-chtml.js"></script>
</head>
<body>
<div class="app-layout">
<!-- Main visualization viewport area -->
<main class="viewport-area">
<!-- Floating Glassmorphic Header -->
<header id="mathHeader" class="floating-header">
<div class="function-editor-row">
<span class="function-editor-spacer" aria-hidden="true"></span>
<div class="function-panel" data-notation="component">
<div class="function-meta" aria-hidden="true">
<span class="notation-component">
<i>F</i>(x,y) = <strong>⟨</strong><i>P</i>(x,y), <i>Q</i>(x,y)<strong>⟩</strong></span>
<span class="notation-basis"><i>F</i>(x,y) = <i>P</i>(x,y)<b>i</b> + <i>Q</i>(x,y)<b>j</b></span>
</div>
<div class="function-component function-component-x">
<span class="function-component-label" aria-hidden="true"><i>P</i>(x,y) =</span>
<span class="fn-part" id="partX" tabindex="0" role="button" aria-label="Edit X component" title="Click to edit"></span>
</div>
<div class="function-component function-component-y">
<span class="function-component-label" aria-hidden="true"><i>Q</i>(x,y) =</span>
<span class="fn-part" id="partY" tabindex="0" role="button" aria-label="Edit Y component" title="Click to edit"></span>
</div>
</div>
<button id="openPresetsBtn" class="btn btn-action preset-trigger" type="button" aria-haspopup="dialog" aria-controls="presetDialog">
<i class="fas fa-th-large" aria-hidden="true"></i>
<span>Presets</span>
</button>
</div>
<div id="fnError" class="error-panel"></div>
</header>
<!-- Canvas Container -->
<div id="canvasContainer">
<!-- Canvas gets injected here by setup() -->
<div id="zoomHud" class="hud-overlay">Range: [-5, 5] × [-5, 5]</div>
<div id="paintHud" class="hud-overlay-center">Click & drag to paint particles</div>
<div id="fieldInspector" class="field-inspector" aria-hidden="true" hidden></div>
<div id="magnitudeLegend" class="magnitude-legend" aria-label="Relative vector magnitude in the current view" hidden>
<span class="magnitude-legend-title">Relative magnitude</span>
<div class="magnitude-color-scale" aria-hidden="true"></div>
<div class="magnitude-length-scale" aria-hidden="true">
<span class="length-sample length-sample-low"></span>
<span class="length-sample length-sample-high"></span>
</div>
<div class="magnitude-legend-labels"><span>Low</span><span>High</span></div>
</div>
</div>
<!-- Floating simulation controls -->
<div class="action-tray" aria-label="Simulator controls">
<div class="action-buttons">
<button class="btn btn-action" id="playPause" title="Play/Pause (P)" aria-label="Play or pause simulation" aria-keyshortcuts="P">
<i class="fas fa-play"></i> <span>Play</span>
</button>
<button class="btn btn-action" id="respawnParticles" title="Seed particle grid (G)" aria-label="Populate visible plane with particle grid" aria-keyshortcuts="G">
<i class="fas fa-braille"></i> <span>Seed Grid</span>
</button>
<button class="btn btn-action" id="clearParticles" title="Clear particles (C)" aria-label="Clear particles" aria-keyshortcuts="C">
<i class="fas fa-trash-alt"></i> <span>Clear</span>
</button>
<button id="toggleInspector" class="btn btn-action" type="button" aria-label="Inspect field values" title="Inspect field values (I)" aria-keyshortcuts="I" aria-pressed="false">
<i class="fas fa-crosshairs" aria-hidden="true"></i> <span>Inspect</span>
</button>
</div>
<div class="action-buttons">
<button id="exportPng" class="btn btn-action" type="button" aria-label="Export canvas as PNG" title="Export canvas as PNG">
<i class="fas fa-download" aria-hidden="true"></i> <span>Export PNG</span>
</button>
<button id="shareLink" class="btn btn-action" type="button" aria-label="Copy a link to this vector field" title="Share this vector field">
<i class="fas fa-share-alt"></i>
</button>
<button id="openHelpBtn" class="btn btn-action" type="button" aria-label="Open instructions" title="How to use the simulator (?)" aria-keyshortcuts="?">
<i class="fas fa-question"></i>
</button>
<button id="toggleDrawerBtn" class="hud-btn" aria-label="Toggle settings panel" title="Toggle settings panel (S)" aria-keyshortcuts="S" aria-expanded="true" aria-controls="controlDrawer">
<i class="fas fa-sliders-h"></i>
</button>
</div>
</div>
</main>
<!-- Collapsible settings drawer/sidebar -->
<aside id="controlDrawer" class="sidebar">
<div class="sidebar-header">
<div>
<h1 class="app-title">Vector Field Simulator</h1>
<h2>Settings</h2>
</div>
<button id="closeDrawerBtn" class="close-btn" aria-label="Close settings panel" title="Close settings panel">×</button>
</div>
<div class="sidebar-body">
<section class="sidebar-section">
<h3>Display</h3>
<div class="toggle-buttons">
<button class="btn btn-toggle" id="toggleParticles" title="Toggle Particles">
<i class="fas fa-eye"></i> Particles
</button>
<button class="btn btn-toggle" id="toggleVectors" title="Toggle vectors (V)" aria-keyshortcuts="V">
<i class="fas fa-arrow-right"></i> Vectors
</button>
<button class="btn btn-toggle" id="toggleAxes" title="Toggle axes (A)" aria-keyshortcuts="A">
<i class="fas fa-arrows-alt"></i> Axes
</button>
<button class="btn btn-toggle" id="toggleGrid" title="Toggle grid lines (L)" aria-keyshortcuts="L">
<i class="fas fa-th"></i> Grid
</button>
</div>
</section>
<section class="sidebar-section">
<h3>Simulation</h3>
<div class="parameter-slider">
<div class="slider-info">
<label for="speedSlider">Speed</label>
<span id="speedValue">1.00</span>
</div>
<input type="range" id="speedSlider" min="0" max="4.0" step="0.05" value="1.00">
</div>
</section>
<section class="sidebar-section">
<h3>Particles</h3>
<div class="parameter-control">
<label for="particleColorMode">Color</label>
<div class="select-container">
<select id="particleColorMode">
<option value="uniform">Uniform</option>
<option value="magnitude">Field magnitude</option>
</select>
</div>
</div>
<div id="particleUniformColorControl" class="solid-preset-grid" role="group" aria-label="Uniform particle color">
<button type="button" class="solid-preset" data-color="#ec4899" style="--preset-color: #ec4899" aria-label="Pink" title="Pink"><span>Pink</span></button>
<button type="button" class="solid-preset" data-color="#00b8c4" style="--preset-color: #00b8c4" aria-label="Cyan" title="Cyan"><span>Cyan</span></button>
<button type="button" class="solid-preset" data-color="#8b5cf6" style="--preset-color: #8b5cf6" aria-label="Violet" title="Violet"><span>Violet</span></button>
<button type="button" class="solid-preset" data-color="#f97316" style="--preset-color: #f97316" aria-label="Orange" title="Orange"><span>Orange</span></button>
</div>
<div class="parameter-slider">
<div class="slider-info">
<label for="particleSizeSlider">Size</label>
<span id="particleSizeValue">8px</span>
</div>
<input type="range" id="particleSizeSlider" min="2" max="20" step="1" value="8">
</div>
<div class="parameter-slider">
<div class="slider-info">
<label for="particleSpacingSlider">Seed Grid Spacing</label>
<span id="particleSpacingValue">0.50</span>
</div>
<input type="range" id="particleSpacingSlider" min="0.25" max="2.0" step="0.05" value="0.50">
</div>
</section>
<section class="sidebar-section">
<h3>Vector Arrows</h3>
<div class="parameter-control">
<label for="vectorMagnitudeMode">Magnitude Encoding</label>
<div class="select-container">
<select id="vectorMagnitudeMode">
<option value="color">Color</option>
<option value="length">Length</option>
<option value="uniform">Uniform</option>
</select>
</div>
</div>
<div id="vectorColorControls" class="gradient-preset-grid" role="group" aria-label="Vector magnitude color palette">
<button type="button" class="gradient-preset" data-low-color="#00f2fe" data-high-color="#ec4899" style="--preset-low: #00f2fe; --preset-high: #ec4899"><span class="gradient-preset-preview"></span><span>Cyan · Pink</span></button>
<button type="button" class="gradient-preset" data-low-color="#440154" data-high-color="#fde725" style="--preset-low: #440154; --preset-high: #fde725"><span class="gradient-preset-preview"></span><span>Viridis</span></button>
<button type="button" class="gradient-preset" data-low-color="#2563eb" data-high-color="#ef4444" style="--preset-low: #2563eb; --preset-high: #ef4444"><span class="gradient-preset-preview"></span><span>Blue · Red</span></button>
<button type="button" class="gradient-preset" data-low-color="#334155" data-high-color="#e2e8f0" style="--preset-low: #334155; --preset-high: #e2e8f0"><span class="gradient-preset-preview"></span><span>Monochrome</span></button>
</div>
<div class="parameter-slider">
<div class="slider-info">
<label for="vectorSpacingSlider">Spacing</label>
<span id="vectorSpacingValue">0.50</span>
</div>
<input type="range" id="vectorSpacingSlider" min="0.25" max="2.0" step="0.05" value="0.50">
</div>
</section>
<section class="sidebar-section">
<h3>Appearance</h3>
<div class="parameter-control">
<label for="themeSelect">Theme</label>
<div class="select-container">
<select id="themeSelect">
<option value="dark">Dark</option>
<option value="light">Light</option>
</select>
</div>
</div>
<div class="parameter-control">
<label for="notationSelect">Function Notation</label>
<div class="select-container">
<select id="notationSelect">
<option value="component">Component · ⟨P, Q⟩</option>
<option value="basis">Basis vectors · P i + Q j</option>
</select>
</div>
</div>
</section>
</div>
<!-- Footer Info -->
<footer class="sidebar-footer">
<a class="sidebar-footer-action" href="https://www.github.com/mbwatson/vectorField" target="_blank" rel="noopener noreferrer" aria-label="View source on GitHub" title="View source on GitHub">
<i class="fab fa-github"></i>
</a>
</footer>
</aside>
</div>
<dialog id="presetDialog" class="help-dialog preset-dialog" aria-labelledby="presetDialogTitle">
<div class="help-dialog-header">
<div>
<p class="help-eyebrow">Examples</p>
<h2 id="presetDialogTitle">Choose a vector field</h2>
</div>
<button id="closePresetsBtn" class="close-btn help-close-btn" type="button" aria-label="Close presets" title="Close presets">×</button>
</div>
<div id="presetDialogBody" class="preset-dialog-body"></div>
</dialog>
<dialog id="helpDialog" class="help-dialog" aria-labelledby="helpDialogTitle">
<div class="help-dialog-header">
<div>
<p class="help-eyebrow">Quick start</p>
<h2 id="helpDialogTitle">Explore the vector field</h2>
</div>
<button id="closeHelpBtn" class="close-btn help-close-btn" type="button" aria-label="Close instructions" title="Close instructions">×</button>
</div>
<div class="help-dialog-body">
<section class="help-section">
<div class="help-section-icon"><i class="fas fa-paint-brush"></i></div>
<div>
<h3>Draw and animate</h3>
<p>Click or drag on the plane to place particles. Use <strong>Play</strong>, <strong>Seed Grid</strong>, and <strong>Clear</strong> to experiment with their motion.</p>
</div>
</section>
<section class="help-section">
<div class="help-section-icon"><i class="fas fa-keyboard"></i></div>
<div>
<h3>Keyboard shortcuts</h3>
<p><kbd>P</kbd> play/pause · <kbd>C</kbd> clear · <kbd>G</kbd> seed grid · <kbd>I</kbd> inspect · <kbd>V</kbd> vectors · <kbd>L</kbd> grid · <kbd>A</kbd> axes · <kbd>S</kbd> settings · <kbd>?</kbd> help · <kbd>Esc</kbd> close or cancel</p>
</div>
</section>
<section class="help-section">
<div class="help-section-icon"><i class="fas fa-edit"></i></div>
<div>
<h3>Change the field</h3>
<p>Click either component of <strong id="notationHelpExample">F(x,y) = ⟨P(x,y), Q(x,y)⟩</strong> to edit it. Press <kbd>Enter</kbd> to apply or <kbd>Escape</kbd> to cancel. Use <strong>Presets</strong> in the function editor to choose an example field.</p>
</div>
</section>
<section class="help-section">
<div class="help-section-icon"><i class="fas fa-search"></i></div>
<div>
<h3>Explore the plane</h3>
<p>Scroll or pinch to zoom. Pan with a right-button drag, middle-button drag, or <kbd>Space</kbd> + drag. On touchscreens, drag with two fingers.</p>
</div>
</section>
<section class="help-section">
<div class="help-section-icon"><i class="fas fa-sliders-h"></i></div>
<div>
<h3>Customize and share</h3>
<p>Vector arrows can show relative magnitude in the current view through color or length, or use a uniform direction-only style. Share copies only the current vector field, so recipients keep their own preferences.</p>
</div>
</section>
<details class="syntax-help">
<summary>Supported math syntax</summary>
<div class="syntax-help-content">
<p>Use <code>x</code>, <code>y</code>, the operators <code>+ - * / ^</code>, and the constants <code>pi</code> and <code>e</code>.</p>
<p>Functions include <code>sin</code>, <code>cos</code>, <code>tan</code>, <code>sec</code>, <code>csc</code>, <code>cot</code>, inverse and hyperbolic trig functions, <code>exp</code>, <code>ln</code>, <code>log</code>, <code>sqrt</code>, and <code>abs</code>.</p>
<p>Implicit multiplication works too: <code>2x</code>, <code>xy</code>, <code>2sin(x)</code>, and <code>(x+1)(x-1)</code>.</p>
</div>
</details>
</div>
</dialog>
</body>
</html>