3 ms·
There is, ResizeObserver -> device-pixel-content-box But ATM it's Chromium browsers only. Some examples on this page https://webglfundamentals.org/webgl/less
by greggman3 6y ago
There is, ResizeObserver -> device-pixel-content-box But ATM it's Chromium browsers only.
Some examples on this page
https://webglfundamentals.org/webgl/lessons/webgl-resizing-the-canvas.html https://webglfundamentals.org/webgl/lessons/webgl-resizing-t...
Bugs filed for other browsers but AFAICT it's not a priority for them.
Note: For a pixelated game having this info useful. Also for diagrams, as the user zooms in you'd like to be able to re-render a canvas at native resolution the same way SVG and text gets re-rendered. But, a noticeable problem is static images. You make pixelated image say, 100x50 and display it 4x like this
<img src="100x50.png" style="width: 400px; height: 200px; image-rendering: pixelated;">
But, what's the browser supposed to do with that on a screen with 1.25 devicePixelRatio? It will look like crap.
- jan_Inkepa 6y agoAt someone's recommendation a while ago I made a proposal for integer-multiple upscaling - https://github.com/w3c/csswg-drafts/issues/5967 https://github.com/w3c/csswg-drafts/issues/5967 . It feels very niche, especially given how complex the standards already are, but OTOH I'd use it if it were a thing... (Also, that linked page is very cool, and shows how awfully tricky the problem is...none of the proposed solutions work on my iPad, especially not once one zooms in/out in the browser - oh it turns out it was related to browser zoom level - at normal zoom they work (sometimes when I resize the page at normal zoom it works, sometimes it doesn't...). So I guess it's 70% of the way there...but not all the way there).
- greggman3 6y agoThe reason it doesn't work on iPad is because iPad doesn't support the required API. Without that API there is nothing you can except special case per browser and pray. And even then, Safari doesn't change DRP based on zoom level like Firefox and Chrome do so it's currently impossible on Safari period.
- jan_Inkepa 6y agoI've added an event in my calendar to go back to this topic again this day one year from now to see if things have improved any (I skirt with frustration-induced burnout every time it raises its head as relevant, so I need to limit my exposure). Thanks for knowing more than me about this cursed subject matter.