I draw some rectangles and then erase and redraw them to simulate movement to the right. However canvas antialiasing makes them leave traces and I don't want to redraw the entire canvas. Here's what I'm talking about
And here is the code for that:
var canvas = document.getElementById("canvas");
canvas.width = 800;
canvas.height = 600;
var context = canvas.getContext("2d");
maxFps = 15;
function loop(x) {
setTimeout(function() {
undoRect(x);
drawRect(x + 30);
loop(x + 30);
}, 1000/maxFps);
};
function undoRect(x) {
context.clearRect(x, 0, 30, 30);
};
function drawRect(x) {
context.fillStyle = 'black';
context.fillRect(x, 0, 30, 30);
};
loop(0);
