Skip to content

Commit 2b7075a

Browse files
committed
Fixed physical canvas size when using shader-toy.forceResolution
1 parent ea84455 commit 2b7075a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

resources/webview_base.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,10 +425,14 @@
425425
}
426426
function computeSize() {
427427

428+
let forcedResolutions = [<!-- Forced Resolution -->];
429+
let zoom = forcedResolutions[0] > 0 ? 1.0/window.devicePixelRatio : 1.0;
430+
canvas.style.zoom = zoom;
431+
428432
// Compute forced aspect ratio and align canvas
429433
resolution = forceAspectRatio(window.innerWidth, window.innerHeight);
430-
canvas.style.left = `${(window.innerWidth - resolution.x) / 2}px`;
431-
canvas.style.top = `${(window.innerHeight - resolution.y) / 2}px`;
434+
canvas.style.left = `${(window.innerWidth - resolution.x*zoom) / 2}px`;
435+
canvas.style.top = `${(window.innerHeight - resolution.y*zoom) / 2}px`;
432436

433437
for (let buffer of buffers) {
434438
if (buffer.Target) {

0 commit comments

Comments
 (0)