6

For some reason any value of pixel ratio less than 1 does not work in my rendering algorithm. A value of zero does not make sense, however 0.5 does. Is it possible that devicePixelRatio return a value between 0 and 1?

Derek 朕會功夫
  • 92,235
  • 44
  • 185
  • 247

1 Answers1

4

DPR can be less than 1, if you set browser zoom to less than 100%. For a zoom factor of 50%, DPR would be 0.5.

Adjust browser zoom to below 100% and run this snippet, it will log the DPR:

console.log("devicePixelRatio:", window.devicePixelRatio);

Testing with Firefox I got min. DPR of ~0.34, with Chrome I got it down to 0.25.

zett42
  • 25,437
  • 3
  • 35
  • 72