4 ms·
NB, that style does not play well with non-native DPI (e.g. when you have monitor set to 150% scale); to see it mapped to physical pixels, try running this in t
by myfonj 2y ago
NB, that style does not play well with non-native DPI (e.g. when you have monitor set to 150% scale); to see it mapped to physical pixels, try running this in the browser's console:
with(document.documentElement.style){
transform = `scale(${ 1 / devicePixelRatio })`;
transformOrigin = 'top left';
}
(multiply the scale by whole number to get it "crisply zoomed").
Still not 100% perfect, but much closer to intended rendering, I guess.
- paulirish 2y agoWow, your use of `with` is both terrifying and super fresh. I love/hate it.
- phatskat 2y agoI’ll be honest, I didn’t know JS had `with`…off to MDN
- myfonj 2y agohttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/with https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... tl;dr is that `with` is a long deprecated statement that is good for casual "golfing" and raising eyebrows of JS-savvy folks. Does not work in the "use strict" mode (so in modules) and generally should not be used in any "real-world" production code, since it prevents many optimisations and could possibly make the code harder to grasp. But I guess for casual one-time console doodles it could be fine. Reportedly it is supported in all major JS engines, and I don't think it will be really removed in foreseeable future.
- phatskat 2y agoI read the MDN page on it right after my comment and it’s fascinating, and also very understandable why it’s a Bad Idea™