From 532d662722da1fa8cce211ced79da575059d359c Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Thu, 27 Oct 2022 10:12:54 +0100 Subject: js: Very bad attempt at making puzzles change size when zooming This has the entertaining consequence that repeatedly zooming in and out causes puzzles to gradually shrink, thus demonstrating that recording the nominal size correctly will be necessary. --- emcclib.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'emcclib.js') diff --git a/emcclib.js b/emcclib.js index 17fd880..f29137a 100644 --- a/emcclib.js +++ b/emcclib.js @@ -544,12 +544,15 @@ mergeInto(LibraryManager.library, { * size. */ js_canvas_set_size: function(w, h) { + var dpr = window.devicePixelRatio || 1; onscreen_canvas.width = w; offscreen_canvas.width = w; - resizable_div.style.width = w / (window.devicePixelRatio || 1) + "px"; + resizable_div.style.width = w / dpr + "px"; + nominal_width = w / dpr; onscreen_canvas.height = h; offscreen_canvas.height = h; + nominal_height = h / dpr; }, /* -- cgit v1.1