aboutsummaryrefslogtreecommitdiff
path: root/emccpre.js
diff options
context:
space:
mode:
authorBen Harris <bjh21@bjh21.me.uk>2022-11-07 23:02:06 +0000
committerBen Harris <bjh21@bjh21.me.uk>2022-11-08 10:27:02 +0000
commitad9ee5a52470b864f6914ba9b5c2c9ae2d6ab072 (patch)
treef265cb1b0cf504fa9542f1647e506a770bf0e837 /emccpre.js
parente45cd43aaab7af014607b2578ec68a5bbec1b609 (diff)
downloadpuzzles-ad9ee5a52470b864f6914ba9b5c2c9ae2d6ab072.zip
puzzles-ad9ee5a52470b864f6914ba9b5c2c9ae2d6ab072.tar.gz
puzzles-ad9ee5a52470b864f6914ba9b5c2c9ae2d6ab072.tar.bz2
puzzles-ad9ee5a52470b864f6914ba9b5c2c9ae2d6ab072.tar.xz
js: Move much of the handling of device pixel ratios to the mid-end
Now that the mid-end knows how to do it, we can remove some complexity from the front end.
Diffstat (limited to 'emccpre.js')
-rw-r--r--emccpre.js11
1 files changed, 2 insertions, 9 deletions
diff --git a/emccpre.js b/emccpre.js
index 6af3350..d234974 100644
--- a/emccpre.js
+++ b/emccpre.js
@@ -30,12 +30,6 @@ var ctx;
// by js_canvas_end_draw.
var update_xmin, update_xmax, update_ymin, update_ymax;
-// Nominal size of the canvas in CSS pixels. This is set when the
-// canvas is explicitly resized, and used as the basis of calls to
-// midend_size whenever the device pixel ratio changes. That way
-// changes of zoom levels in browsers will generally be reversible.
-var nominal_width, nominal_height;
-
// Module object for Emscripten. We fill in these parameters to ensure
// that Module.run() won't be called until we're ready (we want to do
// our own init stuff first), and that when main() returns nothing
@@ -540,8 +534,7 @@ function initPuzzle() {
* <https://developer.mozilla.org/en-US/docs/Web/API/Window/
* devicePixelRatio> (CC0) to work on older browsers.
*/
- var rescale_puzzle = Module.cwrap('rescale_puzzle',
- 'void', ['number', 'number']);
+ var rescale_puzzle = Module.cwrap('rescale_puzzle', 'void', []);
var mql = null;
var update_pixel_ratio = function() {
var dpr = window.devicePixelRatio;
@@ -549,7 +542,7 @@ function initPuzzle() {
mql.removeListener(update_pixel_ratio);
mql = window.matchMedia(`(resolution: ${dpr}dppx)`);
mql.addListener(update_pixel_ratio);
- rescale_puzzle(nominal_width * dpr, nominal_height * dpr);
+ rescale_puzzle();
}
Module.onRuntimeInitialized = function() {