Skip to content

Commit 305f18f

Browse files
committed
EBEAST: utilities.js: resize_canvas: return the devicepixelratio
Signed-off-by: Tim Janik <[email protected]>
1 parent 4606309 commit 305f18f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ebeast/utilities.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -904,9 +904,10 @@ export function resize_canvas (canvas, csswidth, cssheight, fill_style = false)
904904
* resizes in the absence of other constraints. So to render at screen pixel size, we
905905
* always have to assign canvas.style.{width|height}.
906906
*/
907+
const devicepixelratio = window.devicePixelRatio;
907908
const cw = Math.round (csswidth), ch = Math.round (cssheight);
908-
const pw = Math.round (window.devicePixelRatio * cw);
909-
const ph = Math.round (window.devicePixelRatio * ch);
909+
const pw = Math.round (devicepixelratio * cw);
910+
const ph = Math.round (devicepixelratio * ch);
910911
if (cw != canvas.style.width || ch != canvas.style.height ||
911912
pw != canvas.width || ph != canvas.height || fill_style) {
912913
canvas.style.width = cw + 'px';
@@ -920,9 +921,8 @@ export function resize_canvas (canvas, csswidth, cssheight, fill_style = false)
920921
ctx.fillStyle = fill_style;
921922
ctx.fillRect (0, 0, canvas.width, canvas.height);
922923
}
923-
return true;
924924
}
925-
return false;
925+
return devicepixelratio;
926926
}
927927

928928
/** Draw a horizontal line from (x,y) of width `w` with dashes `d` */

0 commit comments

Comments
 (0)