#[cfg(not(target_arch = "wasm32"))] mod setup { pub fn get_asset_path_string() -> String { std::env::current_dir() .unwrap() .join("assets") .to_str() .unwrap() .to_string() } pub fn initial_size() -> (f32, f32) { (1280.0, 720.0) } pub fn virtual_size() -> (f32, f32) { (1280.0, 720.0) } } #[cfg(target_arch = "wasm32")] mod setup { pub fn get_asset_path_string() -> String { String::from("assets") } pub fn virtual_size() -> (f32, f32) { (1280.0, 720.0) } #[cfg(feature = "no_aspect")] pub fn initial_size() -> (f32, f32) { static default_width: f32 = 1280.0; static default_height: f32 = 720.0; web_sys::window() .and_then(|window: web_sys::Window| { let w = window .inner_width() .ok() .and_then(|val| val.as_f64().map(|v| v as f32)) .unwrap_or(default_width); let h = window .inner_height() .ok() .and_then(|val| val.as_f64().map(|v| v as f32)) .unwrap_or(default_height); Some((w, h)) }) .unwrap_or((default_width, default_height)) } #[cfg(not(feature = "no_aspect"))] pub fn initial_size() -> (f32, f32) { static default_width: f32 = 1280.0; static default_height: f32 = 720.0; static ratio: f32 = 1280.0 / 720.0; web_sys::window() .and_then(|window: web_sys::Window| { let w = window .inner_width() .ok() .and_then(|val| val.as_f64().map(|v| v as f32)) .unwrap_or(default_width); let h = window .inner_height() .ok() .and_then(|val| val.as_f64().map(|v| v as f32)) .unwrap_or(default_height); Some((w, h / ratio)) }) .unwrap_or((default_width, default_height)) } } pub use setup::*;