fabricjs implement a scaling hack to render the canvas nicely on screens with different ratio between pixel on screen and "logic pixels",
As you tagged your question as retina-scaling I think you are asking about that.
if you do not want to use that framework this is basically how it works in pure javascript ( same implementation of fabricjs more or less)
if( window.devicePixelRatio !== 1 ){
var c = document.getElementById('mycanvas') // your canvas
var w = c.width, h = c.height;
// scale the canvas by window.devicePixelRatio
c.setAttribute('width', w*window.devicePixelRatio);
c.setAttribute('height', h*window.devicePixelRatio);
// use css to bring it back to regular size
c.setAttribute('style', 'width:'+w+'px; height:'+h+'px;')
// set the scale of the context
c.getContext('2d').scale(window.devicePixelRatio, window.devicePixelRatio);
}
be aware that a browser has to be retina enabled.
Plese check if those images looks different on your retina screen.
First is retina enabled, secondo not.
(be aware, scary images)
var c = new fabric.StaticCanvas('canvas');
var c2 = new fabric.StaticCanvas('canvas2', {enableRetinaScaling: false});
fabric.Image.fromURL('http://www.free-desktop-backgrounds.net/free-desktop-wallpapers-backgrounds/free-hd-desktop-wallpapers-backgrounds/535693007.jpg', function(img) {
img.scale(0.5);
var circle = new fabric.Circle({radius: 40, fill: 'red', stroke: 'blue', top: 2, left: 2});
c.add(img);
c.add(circle);
c2.add(img);
c2.add(circle);
});
<script src="http://www.deltalink.it/andreab/fabric/fabric.js"></script>
<canvas id="canvas" width="800" height="600"></canvas>
<canvas id="canvas2" width="800" height="600"></canvas>
Link with other picture:
http://www.deltalink.it/andreab/fabric/retina.html
Edit:
Added a vector geometric shape to see if there is more evidence.