mirror of https://github.com/emilk/egui.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
199 lines
6.5 KiB
199 lines
6.5 KiB
6 years ago
|
<!DOCTYPE html>
|
||
|
<html>
|
||
6 years ago
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||
6 years ago
|
|
||
6 years ago
|
<!-- Disable zooming: -->
|
||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
|
||
|
|
||
6 years ago
|
<head>
|
||
3 years ago
|
<title>egui – An immediate mode GUI written in Rust</title>
|
||
6 years ago
|
<style>
|
||
5 years ago
|
html {
|
||
|
/* Remove touch delay: */
|
||
|
touch-action: manipulation;
|
||
|
}
|
||
|
|
||
|
body {
|
||
3 years ago
|
/* Light mode background color for what is not covered by the egui canvas,
|
||
4 years ago
|
or where the egui canvas is translucent. */
|
||
3 years ago
|
background: #909090;
|
||
|
}
|
||
|
|
||
|
@media (prefers-color-scheme: dark) {
|
||
|
body {
|
||
|
/* Dark mode background color for what is not covered by the egui canvas,
|
||
|
or where the egui canvas is translucent. */
|
||
|
background: #404040;
|
||
|
}
|
||
5 years ago
|
}
|
||
|
|
||
5 years ago
|
/* Allow canvas to fill entire web page: */
|
||
5 years ago
|
html,
|
||
|
body {
|
||
|
overflow: hidden;
|
||
5 years ago
|
margin: 0 !important;
|
||
|
padding: 0 !important;
|
||
2 years ago
|
height: 100%;
|
||
|
width: 100%;
|
||
5 years ago
|
}
|
||
4 years ago
|
|
||
4 years ago
|
/* Position canvas in center-top: */
|
||
4 years ago
|
canvas {
|
||
|
margin-right: auto;
|
||
|
margin-left: auto;
|
||
|
display: block;
|
||
|
position: absolute;
|
||
4 years ago
|
top: 0%;
|
||
4 years ago
|
left: 50%;
|
||
4 years ago
|
transform: translate(-50%, 0%);
|
||
4 years ago
|
}
|
||
3 years ago
|
|
||
3 years ago
|
.centered {
|
||
3 years ago
|
margin-right: auto;
|
||
|
margin-left: auto;
|
||
|
display: block;
|
||
|
position: absolute;
|
||
|
top: 50%;
|
||
|
left: 50%;
|
||
|
transform: translate(-50%, -50%);
|
||
3 years ago
|
color: #f0f0f0;
|
||
3 years ago
|
font-size: 24px;
|
||
|
font-family: Ubuntu-Light, Helvetica, sans-serif;
|
||
3 years ago
|
text-align: center;
|
||
3 years ago
|
}
|
||
|
|
||
|
/* ---------------------------------------------- */
|
||
|
/* Loading animation from https://loading.io/css/ */
|
||
|
.lds-dual-ring {
|
||
|
display: inline-block;
|
||
|
width: 24px;
|
||
|
height: 24px;
|
||
|
}
|
||
|
|
||
|
.lds-dual-ring:after {
|
||
|
content: " ";
|
||
|
display: block;
|
||
|
width: 24px;
|
||
|
height: 24px;
|
||
|
margin: 0px;
|
||
|
border-radius: 50%;
|
||
|
border: 3px solid #fff;
|
||
|
border-color: #fff transparent #fff transparent;
|
||
|
animation: lds-dual-ring 1.2s linear infinite;
|
||
|
}
|
||
|
|
||
|
@keyframes lds-dual-ring {
|
||
|
0% {
|
||
|
transform: rotate(0deg);
|
||
|
}
|
||
|
|
||
|
100% {
|
||
|
transform: rotate(360deg);
|
||
|
}
|
||
|
}
|
||
6 years ago
|
</style>
|
||
6 years ago
|
</head>
|
||
|
|
||
|
<body>
|
||
3 years ago
|
<!-- The WASM code will resize the canvas dynamically -->
|
||
4 years ago
|
<canvas id="the_canvas_id"></canvas>
|
||
3 years ago
|
<div class="centered" id="center_text">
|
||
|
<p style="font-size:16px">
|
||
|
Loading…
|
||
|
</p>
|
||
3 years ago
|
<div class="lds-dual-ring"></div>
|
||
|
</div>
|
||
4 years ago
|
|
||
6 years ago
|
<script>
|
||
5 years ago
|
// The `--no-modules`-generated JS from `wasm-bindgen` attempts to use
|
||
|
// `WebAssembly.instantiateStreaming` to instantiate the wasm module,
|
||
|
// but this doesn't work with `file://` urls. This example is frequently
|
||
|
// viewed by simply opening `index.html` in a browser (with a `file://`
|
||
|
// url), so it would fail if we were to call this function!
|
||
|
//
|
||
|
// Work around this for now by deleting the function to ensure that the
|
||
|
// `no_modules.js` script doesn't have access to it. You won't need this
|
||
|
// hack when deploying over HTTP.
|
||
|
delete WebAssembly.instantiateStreaming;
|
||
6 years ago
|
</script>
|
||
6 years ago
|
|
||
6 years ago
|
<!-- this is the JS generated by the `wasm-bindgen` CLI tool -->
|
||
4 years ago
|
<script src="egui_demo_app.js"></script>
|
||
6 years ago
|
|
||
6 years ago
|
<script>
|
||
4 years ago
|
// We'll defer our execution until the wasm is ready to go.
|
||
|
// Here we tell bindgen the path to the wasm file so it can start
|
||
|
// initialization and return to us a promise when it's done.
|
||
2 years ago
|
console.debug("Loading wasm…");
|
||
4 years ago
|
wasm_bindgen("./egui_demo_app_bg.wasm")
|
||
4 years ago
|
.then(on_wasm_loaded)
|
||
2 years ago
|
.catch(on_error);
|
||
5 years ago
|
|
||
|
function on_wasm_loaded() {
|
||
2 years ago
|
console.debug("Wasm loaded. Starting app…");
|
||
3 years ago
|
|
||
2 years ago
|
let handle = new wasm_bindgen.WebHandle();
|
||
2 years ago
|
|
||
|
function check_for_panic() {
|
||
|
if (handle.has_panicked()) {
|
||
|
console.error("The egui app has crashed");
|
||
|
|
||
|
// The demo app already logs the panic message and callstack, but you
|
||
|
// can access them like this if you want to show them in the html:
|
||
|
// console.error(`${handle.panic_message()}`);
|
||
|
// console.error(`${handle.panic_callstack()}`);
|
||
|
|
||
|
document.getElementById("the_canvas_id").remove();
|
||
|
document.getElementById("center_text").innerHTML = `
|
||
|
<p>
|
||
|
The egui app has crashed.
|
||
|
</p>
|
||
2 years ago
|
<p style="font-size:10px" align="left">
|
||
|
${handle.panic_message()}
|
||
|
</p>
|
||
2 years ago
|
<p style="font-size:14px">
|
||
|
See the console for details.
|
||
|
</p>
|
||
|
<p style="font-size:14px">
|
||
|
Reload the page to try again.
|
||
|
</p>`;
|
||
|
} else {
|
||
|
let delay_ms = 1000;
|
||
|
setTimeout(check_for_panic, delay_ms);
|
||
|
}
|
||
|
}
|
||
3 years ago
|
|
||
2 years ago
|
check_for_panic();
|
||
2 years ago
|
|
||
|
handle.start("the_canvas_id").then(on_app_started).catch(on_error);
|
||
|
}
|
||
|
|
||
|
function on_app_started(handle) {
|
||
|
// Call `handle.destroy()` to stop. Uncomment to quick result:
|
||
|
// setTimeout(() => { handle.destroy(); handle.free()) }, 2000)
|
||
|
|
||
|
console.debug("App started.");
|
||
|
document.getElementById("center_text").innerHTML = '';
|
||
3 years ago
|
}
|
||
|
|
||
2 years ago
|
function on_error(error) {
|
||
3 years ago
|
console.error("Failed to start: " + error);
|
||
2 years ago
|
document.getElementById("the_canvas_id").remove();
|
||
3 years ago
|
document.getElementById("center_text").innerHTML = `
|
||
|
<p>
|
||
3 years ago
|
An error occurred during loading:
|
||
3 years ago
|
</p>
|
||
|
<p style="font-family:Courier New">
|
||
|
${error}
|
||
|
</p>
|
||
|
<p style="font-size:14px">
|
||
|
Make sure you use a modern browser with WebGL and WASM enabled.
|
||
|
</p>`;
|
||
5 years ago
|
}
|
||
6 years ago
|
</script>
|
||
|
</body>
|
||
|
|
||
6 years ago
|
</html>
|
||
4 years ago
|
|
||
4 years ago
|
<!-- Powered by egui: https://github.com/emilk/egui/ -->
|