Skip to content

Instantly share code, notes, and snippets.

@ayamflow
Created January 23, 2016 20:26
Show Gist options
  • Save ayamflow/8762a6de831fddab086d to your computer and use it in GitHub Desktop.
Save ayamflow/8762a6de831fddab086d to your computer and use it in GitHub Desktop.
Canvas resize (including retina)
var ratio = window.devicePixelRatio || 1;
var canvas = this.canvas;
canvas.width = ratio * size.width;
canvas.height = ratio * size.height;
canvas.style.width = size.width + 'px';
canvas.style.height = size.height + 'px';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment