UNPKG

sketch

Version:

Sketch canvas drawing component

21 lines (19 loc) 448 B
/** * Retina-enable the given `canvas`. * * @param {Canvas} canvas * @return {Canvas} * @api public */ module.exports = function(canvas){ var ctx = canvas.getContext('2d'); var ratio = window.devicePixelRatio || 1; if (1 != ratio) { canvas.style.width = canvas.width + 'px'; canvas.style.height = canvas.height + 'px'; canvas.width *= ratio; canvas.height *= ratio; ctx.scale(ratio, ratio); } return canvas; };