Scaling HTML Canvas

I did some Googling on how to scale a HTML canvas and found these two SO questions.

HTML5 Canvas resize to fit window

http://stackoverflow.com/questions/1664785/html5-canvas-resize-to-fit-window

 

Scale HTML canvas to browser window size but don’t scale elements within the canvas

http://stackoverflow.com/questions/8684820/scale-html-canvas-to-browser-window-size-but-dont-scale-elements-within-the-can

 

I’ve haven’t played around with the canvas to much to know which approach to take but the answer provided in the HTML5 Canvas resize to fit window question looks like really good implementation too me.

function draw() {
  var ctx = (a canvas context);
  ctx.canvas.width  = window.innerWidth;
  ctx.canvas.height = window.innerHeight;
  //...drawing code...
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s