I have a canvas that always expands to 100% of the screen width when manipulating the browser window. I need the canvas center to always be visible in the center of the browser window even if is in window. The problem is that while I’m expanding the canvas by, for example, 100 px, it expands to the right. Can I somehow anchor this canvas so that it widens evenly left and right ( 50px left and 50 px right in this case)?
incorrectly enlarged canvas
correctly enlarged canvas
The grass has to be canvas in my case.
I tried also to put every sprite in container and move container when resizing window but there are a lot of problems, body position is calculated different and runs away from sprite etc.