Skip to content

Commit 0d926ef

Browse files
committed
Prettify loading screen
1 parent 4bc32b9 commit 0d926ef

File tree

1 file changed

+56
-29
lines changed

1 file changed

+56
-29
lines changed

src/index.html

Lines changed: 56 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta charset="UTF-8">
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77
<title>Complex Plotter</title>
8-
<style>
8+
<style>
99
body, html {
1010
margin: 0;
1111
padding: 0;
@@ -39,6 +39,7 @@
3939
color: white;
4040
font-family: system-ui, -apple-system, sans-serif;
4141
transition: opacity 0.5s ease;
42+
text-align: center;
4243
}
4344
.spinner {
4445
width: 40px;
@@ -47,22 +48,70 @@
4748
border-left-color: #09d;
4849
border-radius: 50%;
4950
animation: spin 1s linear infinite;
50-
margin-bottom: 20px;
51+
margin-bottom: 25px;
5152
}
5253
@keyframes spin { to { transform: rotate(360deg); } }
54+
55+
.tip {
56+
font-size: 1.05em;
57+
color: #e0f7fa;
58+
background: rgba(0, 136, 221, 0.15);
59+
border: 1px solid rgba(0, 153, 221, 0.5);
60+
padding: 10px 20px;
61+
border-radius: 8px;
62+
margin-bottom: 15px;
63+
font-weight: 500;
64+
box-shadow: 0 4px 12px rgba(0,0,0,0.2);
65+
}
66+
67+
h2 {
68+
margin: 10px 0;
69+
font-weight: 600;
70+
}
71+
72+
#fun-fact {
73+
font-style: italic;
74+
color: #aaa;
75+
max-width: 450px;
76+
margin-top: 15px;
77+
min-height: 3em;
78+
margin-bottom: 30px;
79+
line-height: 1.4;
80+
}
81+
5382
</style>
5483
</head>
5584
<body>
5685

5786
<div id="loading-overlay">
5887
<div class="spinner"></div>
59-
<h2 id="progress-text">Loading...</h2>
88+
<h2>Loading...</h2>
89+
<div id="fun-fact"></div>
90+
<div class="tip">Tip: Rescale the UI by pressing Ctrl +/-</div>
6091
</div>
6192

6293
<canvas id="canvas" oncontextmenu="event.preventDefault()" tabindex="-1"></canvas>
94+
6395
<script type="text/javascript">
6496
const canvas = document.getElementById('canvas');
65-
const progressText = document.getElementById('progress-text');
97+
98+
const facts = [
99+
"Fact: In electrical engineering, alternating currents and underdamped circuits are modeled using complex numbers, where the imaginary part naturally represents phase shift.",
100+
"Fact: The Schrödinger equation, the foundational equation of quantum mechanics, explicitly requires complex numbers to describe the wave function of particles.",
101+
"Fact: A qubit's state exists in a two-dimensional complex vector space. The relative complex phase between its states is what unlocks quantum interference.",
102+
"Fact: In aerodynamics, conformal mapping uses complex functions to mathematically transform the complicated airflow around an airplane wing into a simple cylinder.",
103+
"Fact: The Fast Fourier Transform (FFT) uses complex roots of unity to break down signals, whether it's an audio tracks, an image, or any other form of data, into a sum of simple sine waves.",
104+
"Fact: Domain coloring assigns a hue to the complex argument (phase) and brightness to the magnitude, allowing us to visualize 4D complex functions on a 2D screen."
105+
];
106+
107+
const factElement = document.getElementById('fun-fact');
108+
let factIndex = Math.floor(Math.random() * facts.length);
109+
factElement.innerText = facts[factIndex];
110+
111+
const factInterval = setInterval(() => {
112+
factIndex = (factIndex + 1) % facts.length;
113+
factElement.innerText = facts[factIndex];
114+
}, 500);
66115

67116
canvas.addEventListener("webglcontextlost", (e) => {
68117
alert('Error with WebGL. Please reload the page');
@@ -79,38 +128,16 @@ <h2 id="progress-text">Loading...</h2>
79128
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
80129
console.error(text);
81130
},
82-
83-
setStatus: function(text) {
84-
if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
85-
if (text === Module.setStatus.last.text) return;
86-
87-
const m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
88-
if (m) {
89-
const loaded = parseInt(m[2]);
90-
const total = parseInt(m[4]);
91-
const progress = Math.round((loaded / total) * 100);
92-
progressText.innerText = `Loading... ${progress}%`;
93-
} else {
94-
if (text) progressText.innerText = text;
95-
}
96-
},
97-
98-
totalDependencies: 0,
99-
monitorRunDependencies: function(left) {
100-
this.totalDependencies = Math.max(this.totalDependencies, left);
101-
Module.setStatus(left ? `Preparing... (${this.totalDependencies - left}/${this.totalDependencies})` : 'All downloads complete.');
102-
},
103-
104131
onRuntimeInitialized: function() {
132+
clearInterval(factInterval);
133+
105134
document.getElementById('loading-overlay').style.display = 'none';
106135
canvas.focus();
107136
}
108137
};
109-
110-
Module.setStatus('Downloading...');
111138
</script>
139+
112140
<textarea id="clipping" style="position:absolute; width:0; height:0; border:0; opacity:0; pointer-events:none;" aria-hidden="true"></textarea>
113-
114141
<script async type="text/javascript" src="complex-plotter.js"></script>
115142
</body>
116143
</html>

0 commit comments

Comments
 (0)