I want to move a rect from the top to the bottom of the canvas. But somehow the canvas does not get cleared. What is wrong?
JS
(function animloop(){
requestAnimFrame(animloop);
redraw();
})();
function redraw() {
ctx.clearRect(0,0,canvasWidth, canvasHeight);
ctx.rect(20,y,50,50);
ctx.fillStyle="red";
ctx.fill();
y += 2;
}