DesignFission

Flash, Web, Javascript and everything else

Posted on by Edwin


Been working with HTML 5 recently and I ran into a very frustrating problem.

Using CSS to set the width and height of a canvas element stretches the content inside to the new width/height that you set.

Example 1 (will stretch):

	this.canvas.setAttribute('width', w);
	this.canvas.setAttribute('height', h);

To simply resize the area of the canvas element, do this:

	this.canvas.width = w;
	this.canvas.height = h;

Posted on by Edwin | Posted in HTML5


About Edwin

I do code.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>