The canvas fills its container (the editor preview, an embed, a Discord window) and can resize at any time. Read these values each frame instead of storing them once.
#Size
#width / height
The canvas size in pixels.
#centerX / centerY
Half the width and height: the middle of the canvas.
#Frames
#fps
The current frames per second.
#frameCount
The number of frames drawn since the program started.
#The update loop
Codetoy calls your update function once per frame, before showing the canvas. See Program Structure.
#Resize event
Called whenever the canvas changes size, with the new width and height. Use it to recompute layout you cache, like a grid that fits the screen.
Note
C# has no resize callback yet. Compare Screen.Width and Screen.Height with last frame's values in Screen.OnUpdate if you need to react to resizes.