MrFrankel / ruler

HTML5 Canvas ruler for authoring tools
http://mrfrankel.github.io/ruler/
221 stars 56 forks source link

Can it support retina screen? #10

Open wandergis opened 6 years ago

wandergis commented 6 years ago

Can it support retina screen?

MrFrankel commented 6 years ago

Seems to work for me on a macbook screen

wandergis commented 6 years ago

On a retina macbook,the window.devicePixelRatio is 2. https://www.html5rocks.com/en/tutorials/canvas/hidpi/

let pixelRatio = window.devicePixelRatio || 1;
canvas.width = pixelRatio * width;
canvas.height = pixelRatio * height;
canvas.style.width = width + 'px';
canvas.style.height = height + 'px';