From 4642fa024f8ce1e53afc227beb75eef9de3ab946 Mon Sep 17 00:00:00 2001 From: Arman Uguray Date: Sun, 23 Apr 2023 12:00:42 -0700 Subject: [PATCH] [with_winit] Set the canvas size to thw winit Window's inner size This prevents the scaling caused by the hardcoded canvas dimensions on high dpi platforms. --- examples/with_winit/src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/with_winit/src/lib.rs b/examples/with_winit/src/lib.rs index dc46b54..e08add2 100644 --- a/examples/with_winit/src/lib.rs +++ b/examples/with_winit/src/lib.rs @@ -483,8 +483,9 @@ pub fn main() -> Result<()> { let window = create_window(&event_loop); // On wasm, append the canvas to the document body let canvas = window.canvas(); - canvas.set_width(1044); - canvas.set_height(800); + let size = window.inner_size(); + canvas.set_width(size.width); + canvas.set_height(size.height); web_sys::window() .and_then(|win| win.document()) .and_then(|doc| doc.body())