I thought this would be the kind of thing there would be plenty of tutorials on, however every one I found was either over-complicated, vague, or used features not yet widely supported. So, I decided to try it on my own. My code is below.
function drawStuff(){
var x = document.getElementById("myCanvas");
var canvas = x.getContext('2d');
var i;
function animate(){
canvas.clearRect(0,0,500,500);
canvas.fillStyle="red";
canvas.fillRect(0,i,50,50);
i++;
}
windows.setInterval(animate(), 125);
}
window.addEventListener("load", drawStuff, false);
Why isn't this working? Do I misunderstand what the setInterval does? Any help is appreciated.