I'm doing it this way: canvas.width = myWidth * window.devicePixelRatio;canvas.height = myHeight * window.devicePixelRatio;canvas.style.width = myWidth + "px";canvas.style.height = myHeight + "px";