mirror of
https://github.com/emilk/egui.git
synced 2026-08-29 04:40:03 -04:00
Deploying to gh-pages from @ emilk/egui@5d3e958ecf 🚀
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
egui_demo_app_bg.wasm
|
||||||
|
egui_demo_app.js
|
||||||
9
README.md
Normal file
9
README.md
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
This folder contains the files required for the egui web demo hosted at <https://www.egui.rs/>.
|
||||||
|
|
||||||
|
## Testing locally
|
||||||
|
* Build with `scripts/build_demo_web.sh`
|
||||||
|
* Host with `scripts/start_server.sh`
|
||||||
|
* Open <http://localhost:8765/index.html>
|
||||||
|
|
||||||
|
## Deploying egui.rs
|
||||||
|
Each merge into `main` will trigger a new deploy
|
||||||
3531
egui_demo_app.js
Normal file
3531
egui_demo_app.js
Normal file
File diff suppressed because it is too large
Load Diff
BIN
egui_demo_app_bg.wasm
Normal file
BIN
egui_demo_app_bg.wasm
Normal file
Binary file not shown.
12
example.html
Normal file
12
example.html
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="refresh" content="0; url = https://www.egui.rs/#http" />
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
BIN
favicon.ico
Normal file
BIN
favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
202
index.html
Normal file
202
index.html
Normal file
@@ -0,0 +1,202 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
|
|
||||||
|
<!-- Disable zooming: -->
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>egui – An immediate mode GUI written in Rust</title>
|
||||||
|
<style>
|
||||||
|
html {
|
||||||
|
/* Remove touch delay: */
|
||||||
|
touch-action: manipulation;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
/* Light mode background color for what is not covered by the egui canvas,
|
||||||
|
or where the egui canvas is translucent. */
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Allow canvas to fill entire web page: */
|
||||||
|
html,
|
||||||
|
body {
|
||||||
|
overflow: hidden;
|
||||||
|
margin: 0 !important;
|
||||||
|
padding: 0 !important;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Make canvas fill entire document: */
|
||||||
|
canvas {
|
||||||
|
margin-right: auto;
|
||||||
|
margin-left: auto;
|
||||||
|
display: block;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.centered {
|
||||||
|
margin-right: auto;
|
||||||
|
margin-left: auto;
|
||||||
|
display: block;
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
color: #f0f0f0;
|
||||||
|
font-size: 24px;
|
||||||
|
font-family: Ubuntu-Light, Helvetica, sans-serif;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------- */
|
||||||
|
/* 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<canvas id="the_canvas_id"></canvas>
|
||||||
|
|
||||||
|
<div class="centered" id="center_text">
|
||||||
|
<p style="font-size:16px">
|
||||||
|
Loading…
|
||||||
|
</p>
|
||||||
|
<div class="lds-dual-ring"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// 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;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<!-- this is the JS generated by the `wasm-bindgen` CLI tool -->
|
||||||
|
<script src="./egui_demo_app.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// 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.
|
||||||
|
console.debug("Loading wasm…");
|
||||||
|
wasm_bindgen("./egui_demo_app_bg.wasm")
|
||||||
|
.then(on_wasm_loaded)
|
||||||
|
.catch(on_error);
|
||||||
|
|
||||||
|
function on_wasm_loaded() {
|
||||||
|
console.debug("Wasm loaded. Starting app…");
|
||||||
|
|
||||||
|
let handle = new wasm_bindgen.WebHandle();
|
||||||
|
|
||||||
|
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>
|
||||||
|
<p style="font-size:10px" align="left">
|
||||||
|
${handle.panic_message()}
|
||||||
|
</p>
|
||||||
|
<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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
check_for_panic();
|
||||||
|
|
||||||
|
handle.start(document.getElementById("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 = '';
|
||||||
|
|
||||||
|
// Make sure the canvas is focused so it can receive keyboard events right away:
|
||||||
|
document.getElementById("the_canvas_id").focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
function on_error(error) {
|
||||||
|
console.error("Failed to start: " + error);
|
||||||
|
document.getElementById("the_canvas_id").remove();
|
||||||
|
document.getElementById("center_text").innerHTML = `
|
||||||
|
<p>
|
||||||
|
An error occurred during loading:
|
||||||
|
</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>`;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
|
|
||||||
|
<!-- Powered by egui: https://github.com/emilk/egui/ -->
|
||||||
183
multiple_apps.html
Normal file
183
multiple_apps.html
Normal file
@@ -0,0 +1,183 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
|
|
||||||
|
<!-- Disable zooming: -->
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>egui – An immediate mode GUI written in Rust</title>
|
||||||
|
<style>
|
||||||
|
html {
|
||||||
|
/* Remove touch delay: */
|
||||||
|
touch-action: manipulation;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
/* Light mode background color for what is not covered by the egui canvas,
|
||||||
|
or where the egui canvas is translucent. */
|
||||||
|
background: #909090;
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
@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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Allow canvas to fill entire web page: */
|
||||||
|
html,
|
||||||
|
body {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
canvas {
|
||||||
|
margin: 8px;
|
||||||
|
padding: 8px;
|
||||||
|
width: 45%;
|
||||||
|
height: 110%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.centered {
|
||||||
|
margin-right: auto;
|
||||||
|
margin-left: auto;
|
||||||
|
display: block;
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
color: #f0f0f0;
|
||||||
|
font-size: 24px;
|
||||||
|
font-family: Ubuntu-Light, Helvetica, sans-serif;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------- */
|
||||||
|
/* 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<!-- The WASM code will resize the canvas dynamically -->
|
||||||
|
|
||||||
|
<button class="stop_one">
|
||||||
|
Stop one app
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<canvas id="canvas_id_one"></canvas>
|
||||||
|
|
||||||
|
<canvas id="canvas_id_two"></canvas>
|
||||||
|
|
||||||
|
<div class="centered" id="center_text">
|
||||||
|
<p style="font-size:16px">
|
||||||
|
Loading…
|
||||||
|
</p>
|
||||||
|
<div class="lds-dual-ring"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// 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;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<!-- this is the JS generated by the `wasm-bindgen` CLI tool -->
|
||||||
|
<script src="egui_demo_app.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// 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.
|
||||||
|
console.debug("Loading wasm…");
|
||||||
|
wasm_bindgen("./egui_demo_app_bg.wasm")
|
||||||
|
.then(on_wasm_loaded)
|
||||||
|
.catch(on_error);
|
||||||
|
|
||||||
|
function on_wasm_loaded() {
|
||||||
|
console.debug("Wasm loaded. Starting apps…");
|
||||||
|
|
||||||
|
// This call installs a bunch of callbacks and then returns:
|
||||||
|
|
||||||
|
const handle_one = new wasm_bindgen.WebHandle();
|
||||||
|
const handle_two = new wasm_bindgen.WebHandle();
|
||||||
|
|
||||||
|
Promise.all([
|
||||||
|
handle_one.start(document.getElementById("canvas_id_one")),
|
||||||
|
handle_two.start(document.getElementById("canvas_id_two")),
|
||||||
|
]).then((handles) => {
|
||||||
|
on_apps_started(handle_one, handle_two)
|
||||||
|
}).catch(on_error);
|
||||||
|
}
|
||||||
|
|
||||||
|
function on_apps_started(handle_one, handle_two) {
|
||||||
|
const button = document.getElementsByClassName("stop_one")[0]
|
||||||
|
|
||||||
|
button.addEventListener("click", () => {
|
||||||
|
document.getElementById("canvas_id_one").remove()
|
||||||
|
handle_one.destroy()
|
||||||
|
handle_one.free()
|
||||||
|
});
|
||||||
|
|
||||||
|
// Call `handle.destroy()` to stop. Uncomment to quick result:
|
||||||
|
// setTimeout(() => { handle.destroy() }, 2000)
|
||||||
|
|
||||||
|
console.debug("Apps started.");
|
||||||
|
document.getElementById("center_text").remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
function on_error(error) {
|
||||||
|
console.error("Failed to start: " + error);
|
||||||
|
document.getElementById("center_text").innerHTML = `
|
||||||
|
<p>
|
||||||
|
An error occurred during loading:
|
||||||
|
</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>`;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
|
|
||||||
|
<!-- Powered by egui: https://github.com/emilk/egui/ -->
|
||||||
Reference in New Issue
Block a user