mirror of
https://github.com/rust-windowing/winit.git
synced 2026-08-30 13:20:06 -04:00
Add web_aspect_ratio example (#2209)
* Add web_aspect_ratio example * Review feedback
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user