I've just started learning HTML canvas, and i can't even make the simplest functionality work properly. fillRect() produces odd results, that are inconsistent with the documentation and a tutorial that i watched.
Here is the html:
<style>
canvas{
width: 500px;
height: 500px;
background-color: aqua;
border: 1px solid black;
}
</style>
<body>
<canvas id="canvas"></canvas>
<script src="canvas.js"></script>
</body>
The Javascript:
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'green';
ctx.fillRect(10, 10, 100, 100);
And here is the completely messed-up result:
As you can see, both the y coordinate and the height are completely wrong. I've tried playing with it, tried both Chrome and Firefox- same result.
What am i missing here?