Skip to content

Commit

Permalink
Use line_demo in plot_demo to replace original UI.
Browse files Browse the repository at this point in the history
Just for test how to use eframe_template.
  • Loading branch information
crazyskady committed Mar 17, 2024
1 parent b15d5bf commit 23aa2e7
Show file tree
Hide file tree
Showing 12 changed files with 283 additions and 84 deletions.
50 changes: 30 additions & 20 deletions eframe_test/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion eframe_test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "eframe_template"
name = "plot_test"
version = "0.1.0"
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
edition = "2021"
Expand All @@ -15,6 +15,7 @@ eframe = { version = "0.26.0", default-features = false, features = [
"persistence", # Enable restoring app state when restarting the app.
] }
log = "0.4"
egui_plot = "0.26.2"

# You only need serde if you want app persistence:
serde = { version = "1", features = ["derive"] }
Expand Down
Binary file added eframe_test/assets/ferris.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions eframe_test/assets/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ var cacheName = 'egui-template-pwa';
var filesToCache = [
'./',
'./index.html',
'./eframe_template.js',
'./eframe_template_bg.wasm',
'./plot_test.js',
'./plot_test_bg.wasm',
];

/* Start the service worker and cache all of the app's content */
Expand Down
8 changes: 4 additions & 4 deletions eframe_test/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<!-- config for our rust wasm binary. go to https://trunkrs.dev/assets/#rust for more customization -->

<script type="module">
import init, * as bindings from '/eframe_test-59d67a527e6b52c8.js';
init('/eframe_test-59d67a527e6b52c8_bg.wasm');
import init, * as bindings from '/plot_test-80210dae30f2a961.js';
init('/plot_test-80210dae30f2a961_bg.wasm');
window.wasmBindings = bindings;

</script>
Expand Down Expand Up @@ -121,8 +121,8 @@

</style>

<link rel="preload" href="/eframe_test-59d67a527e6b52c8_bg.wasm" crossorigin="anonymous" integrity="sha384-XAfyElckCoEJNHF8bgxwwHNwIukqojEdSqi0azf4DzuY2Gg9YGI82dmtXjv1giT4" as="fetch" type="application/wasm">
<link rel="modulepreload" href="/eframe_test-59d67a527e6b52c8.js" crossorigin="anonymous" integrity="sha384-lH-nKUVxWRBW7x97fcoem78O1vXrpyStf4xyToKxnmw2iEE8FzgGu1wY1mnGFwVT"></head>
<link rel="preload" href="/plot_test-80210dae30f2a961_bg.wasm" crossorigin="anonymous" integrity="sha384-NAbP4BLSJL9kozKHztj3-ids0ujM8r0ICd7X-518SZ4_wIefxK6P2geZrj8FXuqg" as="fetch" type="application/wasm">
<link rel="modulepreload" href="/plot_test-80210dae30f2a961.js" crossorigin="anonymous" integrity="sha384-KhpAHk5ZY49xvcdiXZ2Gzl86xBF0cee-AkoDtGFb3b8uLCU4hIdQ7lAi6cEogCr2"></head>

<body>
<!-- The WASM code will resize the canvas dynamically -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
let wasm;

const heap = new Array(128).fill(undefined);

heap.push(undefined, null, true, false);

function getObject(idx) { return heap[idx]; }

let heap_next = heap.length;

function dropObject(idx) {
if (idx < 132) return;
heap[idx] = heap_next;
heap_next = idx;
}

function takeObject(idx) {
const ret = getObject(idx);
dropObject(idx);
return ret;
}

const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );

if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
Expand All @@ -18,12 +38,6 @@ function getStringFromWasm0(ptr, len) {
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
}

const heap = new Array(128).fill(undefined);

heap.push(undefined, null, true, false);

let heap_next = heap.length;

function addHeapObject(obj) {
if (heap_next === heap.length) heap.push(heap.length + 1);
const idx = heap_next;
Expand All @@ -33,20 +47,6 @@ function addHeapObject(obj) {
return idx;
}

function getObject(idx) { return heap[idx]; }

function dropObject(idx) {
if (idx < 132) return;
heap[idx] = heap_next;
heap_next = idx;
}

function takeObject(idx) {
const ret = getObject(idx);
dropObject(idx);
return ret;
}

let WASM_VECTOR_LEN = 0;

const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
Expand Down Expand Up @@ -213,18 +213,18 @@ function makeMutClosure(arg0, arg1, dtor, f) {

return real;
}
function __wbg_adapter_26(arg0, arg1, arg2) {
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hdcd085509879f7bc(arg0, arg1, addHeapObject(arg2));
function __wbg_adapter_26(arg0, arg1) {
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hb22dcb4bed310eac(arg0, arg1);
}

function __wbg_adapter_29(arg0, arg1) {
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h33f127408e6c9c1b(arg0, arg1);
function __wbg_adapter_29(arg0, arg1, arg2) {
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h1664b4f0da6a3d84(arg0, arg1, addHeapObject(arg2));
}

function __wbg_adapter_32(arg0, arg1) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h10e28e3bbe5efbac(retptr, arg0, arg1);
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h31c639a64d5147df(retptr, arg0, arg1);
var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1];
if (r1) {
Expand Down Expand Up @@ -281,10 +281,6 @@ async function __wbg_load(module, imports) {
function __wbg_get_imports() {
const imports = {};
imports.wbg = {};
imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
const ret = getStringFromWasm0(arg0, arg1);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
takeObject(arg0);
};
Expand All @@ -297,6 +293,10 @@ function __wbg_get_imports() {
const ret = false;
return ret;
};
imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
const ret = getStringFromWasm0(arg0, arg1);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
const obj = getObject(arg1);
const ret = typeof(obj) === 'string' ? obj : undefined;
Expand Down Expand Up @@ -1326,20 +1326,20 @@ function __wbg_get_imports() {
const ret = wasm.memory;
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper2508 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 202, __wbg_adapter_26);
imports.wbg.__wbindgen_closure_wrapper3463 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 289, __wbg_adapter_26);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper2510 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 202, __wbg_adapter_29);
imports.wbg.__wbindgen_closure_wrapper3465 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 289, __wbg_adapter_29);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper2512 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 202, __wbg_adapter_32);
imports.wbg.__wbindgen_closure_wrapper3467 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 289, __wbg_adapter_32);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper2766 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 283, __wbg_adapter_35);
imports.wbg.__wbindgen_closure_wrapper3721 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 369, __wbg_adapter_35);
return addHeapObject(ret);
};

Expand Down Expand Up @@ -1381,7 +1381,7 @@ async function __wbg_init(input) {
if (wasm !== undefined) return wasm;

if (typeof input === 'undefined') {
input = new URL('eframe_test_bg.wasm', import.meta.url);
input = new URL('plot_test_bg.wasm', import.meta.url);
}
const imports = __wbg_get_imports();

Expand Down
Binary file not shown.
4 changes: 2 additions & 2 deletions eframe_test/dist/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ var cacheName = 'egui-template-pwa';
var filesToCache = [
'./',
'./index.html',
'./eframe_test.js',
'./eframe_test_bg.wasm',
'./plot_test.js',
'./plot_test_bg.wasm',
];

/* Start the service worker and cache all of the app's content */
Expand Down
2 changes: 1 addition & 1 deletion eframe_test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<head>
<!-- change this to your project name -->
<title>eframe template</title>
<title>eframe test</title>

<!-- config for our rust wasm binary. go to https://trunkrs.dev/assets/#rust for more customization -->
<link data-trunk rel="rust" data-wasm-opt="2" />
Expand Down
2 changes: 1 addition & 1 deletion eframe_test/rust-toolchain
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
# to the user in the error, instead of "error: invalid channel name '[toolchain]'".

[toolchain]
channel = "1.72.0"
channel = "1.76.0"
components = [ "rustfmt", "clippy" ]
targets = [ "wasm32-unknown-unknown" ]
Loading

0 comments on commit 23aa2e7

Please sign in to comment.