So, I’ve tried to make a canvas that takes up the entire browser window without stretching the drawings, but every time I try to fix it, it stretches in every case, or returns an error.
let canvas = document.getElementById(“canvas”);
let ctx = canvas.getContext(“2d”);
// just sets the canvas drawing surface size to 0px X 0px
canvas.width = canvas.style.width;
canvas.height = canvas.style.height;
Problem #1 with that: The “Resize” event is not triggered at the beginning
Problem #2: For some reason, when the window DOES resize, it just sets it to 0 x 0.
It is possible that the browser might affect it, but when I tested it, the canvas was resized correctly. I checked the values in the console and they weren’t at 0 after resizing.
I also updated my previous answer to solve problem 1