mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-02 06:41:14 +00:00
Add simple rust wasm test
Needs an initial "npm install" and then "npm start" will build and launch it in the browser.
This commit is contained in:
parent
6110e4952d
commit
e313f39490
8 changed files with 118 additions and 0 deletions
36
examples/rustwasmtest/src/lib.rs
Normal file
36
examples/rustwasmtest/src/lib.rs
Normal file
|
@ -0,0 +1,36 @@
|
|||
use wasm_bindgen::prelude::*;
|
||||
|
||||
// Using a macro for now. But there could be others ways to do that
|
||||
sixtyfps::sixtyfps! {
|
||||
SuperSimple = Rectangle {
|
||||
color: white;
|
||||
|
||||
Rectangle {
|
||||
width: 100;
|
||||
height: 100;
|
||||
color: blue;
|
||||
}
|
||||
Rectangle {
|
||||
x: 100;
|
||||
y: 100;
|
||||
width: (100);
|
||||
height: {100}
|
||||
color: green;
|
||||
}
|
||||
Image {
|
||||
x: 200;
|
||||
y: 200;
|
||||
source: "../../examples/graphicstest/logo.png";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen(start))]
|
||||
pub fn wasm_main() {
|
||||
// This provides better error messages in debug mode.
|
||||
// It's disabled in release mode so it doesn't bloat up the file size.
|
||||
#[cfg(debug_assertions)]
|
||||
console_error_panic_hook::set_once();
|
||||
|
||||
SuperSimple::default().run();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue