Revert "Fix Window::set_inner_size()"

This reverts commit e220a75556.
This commit is contained in:
dAxpeDDa 2023-06-08 08:40:26 +02:00 committed by daxpedda
parent 9797ed86f0
commit b5785ba785
2 changed files with 11 additions and 6 deletions

View file

@ -73,11 +73,17 @@ pub fn scale_factor(window: &web_sys::Window) -> f64 {
pub fn set_canvas_size(canvas: &Canvas, new_size: Size) {
let scale_factor = scale_factor(canvas.window());
let new_size = new_size.to_physical(scale_factor);
canvas.size().set(new_size);
set_canvas_style_property(canvas.raw(), "width", &format!("{}px", new_size.width));
set_canvas_style_property(canvas.raw(), "height", &format!("{}px", new_size.height));
let physical_size = new_size.to_physical(scale_factor);
canvas.size().set(physical_size);
let logical_size = new_size.to_logical::<f64>(scale_factor);
set_canvas_style_property(canvas.raw(), "width", &format!("{}px", logical_size.width));
set_canvas_style_property(
canvas.raw(),
"height",
&format!("{}px", logical_size.height),
);
}
pub fn set_canvas_style_property(raw: &HtmlCanvasElement, property: &str, value: &str) {