Created
March 2, 2026 01:28
-
-
Save easierbycode/7308c46f4e04efd32142062b7146522c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function fitCanvas() { | |
| var c = document.querySelector("#canvas canvas"); | |
| if (!c) return; | |
| var vw = window.innerWidth; | |
| var vh = window.innerHeight; | |
| var scale = Math.min(vw / 256, vh / 480); | |
| c.style.width = Math.floor(256 * scale) + "px"; | |
| c.style.height = Math.floor(480 * scale) + "px"; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment