Add web_aspect_ratio example (#2209)
* Add web_aspect_ratio example * Review feedback
This commit is contained in:
parent
29419d6c38
commit
97d2aaa953
3 changed files with 107 additions and 3 deletions
|
|
@ -15,7 +15,7 @@ pub fn main() {
|
|||
.unwrap();
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let log_list = wasm::create_log_list(&window);
|
||||
let log_list = wasm::insert_canvas_and_create_log_list(&window);
|
||||
|
||||
event_loop.run(move |event, _, control_flow| {
|
||||
control_flow.set_wait();
|
||||
|
|
@ -49,7 +49,7 @@ mod wasm {
|
|||
super::main();
|
||||
}
|
||||
|
||||
pub fn create_log_list(window: &Window) -> web_sys::Element {
|
||||
pub fn insert_canvas_and_create_log_list(window: &Window) -> web_sys::Element {
|
||||
use winit::platform::web::WindowExtWebSys;
|
||||
|
||||
let canvas = window.canvas();
|
||||
|
|
@ -58,7 +58,7 @@ mod wasm {
|
|||
let document = window.document().unwrap();
|
||||
let body = document.body().unwrap();
|
||||
|
||||
// Set a background color for the canvas to make it easier to tell the where the canvas is for debugging purposes.
|
||||
// Set a background color for the canvas to make it easier to tell where the canvas is for debugging purposes.
|
||||
canvas.style().set_css_text("background-color: crimson;");
|
||||
body.append_child(&canvas).unwrap();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue