petabytekr / explorercanvas

Automatically exported from code.google.com/p/explorercanvas
Apache License 2.0
0 stars 0 forks source link

wrong height dimension adding a canvas element programmatically via DOM #62

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
var domElement = document.createElement('canvas');
domElement.setAttribute('width', 300);
domElement.setAttribute('height', 300);
document.body.appendChild(domElement);

Renders a canvas with a wrong height size.
Exactly a 300*150 size canvas instead of a 300*300 one.

Original issue reported on code.google.com by michele....@gmail.com on 21 Dec 2009 at 2:24

GoogleCodeExporter commented 9 years ago
It will make a 300 pixels by 300 pixels canvas, with the default CSS size 300px 
* 
150px. You will notice this if you draw a square on your canvas : it won't be 
square, 
but rectangular because of the default canvas' CSS size. You need to specify 
the CSS 
size : style="width: 300px; height: 300px;" and the canvas size as you did.

Original comment by fabien.menager on 21 Dec 2009 at 2:46