0

I'm working on a game using only html5 canvas element and javascript. i need to be able to re-size it, but don't want to use any librarys

Alexis Dumas
  • 1,299
  • 11
  • 30

1 Answers1

0

You can simply change the width and height of the canvas by assigning it to a variable, and use the width and height properties.

var canvas = document.getElementById("ID of canvas here");
canvas.width = 500;
canvas.height = 500;
  • ...and keep in mind that resizing the canvas will automatically clear all its contents. Therefore, you will have to redraw all the objects on your resized canvas. – markE Mar 01 '13 at 19:11