You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functionsetupCanvas(canvas){// Get the device pixel ratio, falling back to 1.vardpr=window.devicePixelRatio||1;// Get the size of the canvas in CSS pixels.varrect=canvas.getBoundingClientRect();// Give the canvas pixel dimensions of their CSS// size * the device pixel ratio.canvas.width=rect.width*dpr;canvas.height=rect.height*dpr;varctx=canvas.getContext('2d');// Scale all drawing operations by the dpr, so you// don't have to worry about the difference.ctx.scale(dpr,dpr);returnctx;}// Now this line will be the same size on the page// but will look sharper on high-DPI devices!varctx=setupCanvas(document.querySelector('.my-canvas'));ctx.lineWidth=5;ctx.beginPath();ctx.moveTo(100,100);ctx.lineTo(200,200);ctx.stroke();
https://www.html5rocks.com/en/tutorials/canvas/hidpi/
The text was updated successfully, but these errors were encountered: