Been a while been busy ...
From my css file
Code:
canvas.main
{
width:100%;
height:40%;
}
the canvas element
Code:
<canvas id="main" class="main" onClick="javascript:draw()">
This text is displayed if your browser does not support HTML5 Canvas.
</canvas>
And the script. Draw a red and blue rectangle with a width and height of 10 aka a square
Code:
function draw()
{
var example = document.getElementById('main');
var context = example.getContext('2d');
context.fillStyle = "rgb(255,0,0)";
context.fillRect(0, 0, 10, 10);
context.fillStyle = "rgb(0,0,255)";
context.fillRect(20, 20, 10, 10);
}
Result -- 2 rectangles not squares
If i change the canvas size to 100% 100% they are squares ... although not 10 px each. Tested in chrome and firefox