It came to my attention that the <canvas>
element can be adjusted to have varying scales. For example, if I specify the CSS width and height as 100px but use JavaScript to set them to 200px, the element will shrink so that everything drawn on it appears at half the size (or double the resolution).
As a proud owner of a retina screen Macbook Pro, I often work with a 2x scaling factor during development to ensure that images and objects display clearly and sharply on my screen.
I've heard that other screens may have resolutions with a 1.2x difference between CSS pixels and actual pixels.
Is there a method to determine the device's screen resolution or scaling so that I can optimize my canvas for maximum crispness and clarity for users?
Just to provide context, I am currently working on building a game in JavaScript using canvas as the platform for graphics output.