49 lines
1.3 KiB
Rust
49 lines
1.3 KiB
Rust
use eframe::egui;
|
|
use eframe::*;
|
|
|
|
#[cfg(not(target_arch = "wasm32"))]
|
|
fn main() -> eframe::Result {
|
|
env_logger::init();
|
|
log::info!("Shrimp!");
|
|
|
|
let native_options = eframe::NativeOptions {
|
|
viewport: egui::ViewportBuilder::default().with_title("Shrimp"),
|
|
..Default::default()
|
|
};
|
|
eframe::run_native(
|
|
"PlateToolEframe",
|
|
native_options,
|
|
Box::new(|cc| Ok(Box::new(plate_tool_eframe::PlateToolEframe::new(cc)))),
|
|
)
|
|
}
|
|
|
|
#[cfg(target_arch = "wasm32")]
|
|
fn main() {
|
|
use eframe::wasm_bindgen::JsCast as _;
|
|
|
|
eframe::WebLogger::init(log::LevelFilter::Info).ok();
|
|
|
|
let web_options = eframe::WebOptions::default();
|
|
|
|
wasm_bindgen_futures::spawn_local(async {
|
|
let document = web_sys::window()
|
|
.expect("No window")
|
|
.document()
|
|
.expect("No document");
|
|
|
|
let canvas = document
|
|
.get_element_by_id("main_canvas")
|
|
.expect("Canvas id not found")
|
|
.dyn_into::<web_sys::HtmlCanvasElement>()
|
|
.expect("Canvas was not a HtmlCanvasElement");
|
|
|
|
let start_result = eframe::WebRunner::new()
|
|
.start(
|
|
canvas,
|
|
web_options,
|
|
Box::new(|cc| Ok(Box::new(plate_tool_eframe::PlateToolEframe::new(cc)))),
|
|
)
|
|
.await;
|
|
});
|
|
}
|