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
Asked
Active
Viewed 283 times
0
-
possible duplicate of: http://stackoverflow.com/questions/331052/how-to-resize-html-canvas-element – PlantTheIdea Mar 01 '13 at 18:41
1 Answers
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