I have start to programming in html5 i found a lot of resource but i have a question.
In my simple script there are two element. One element is animated and the other one is not animated. Can you learn how to not clear the element not animated in the canvas?
Thank’s here my code.
const canvas = document.createElement('canvas');
canvas.width = "1000";
canvas.height = "500";
const ctx = canvas.getContext('2d');
ctx.fillStyle = "orange";
ctx.rect(0,100,canvas.width,50);
ctx.fill();
var i = 0;
function frame(){
ctx.clearRect(0,0,canvas.width,canvas.height);
i++;
if(i == canvas.height){i = 0}
ctx.font = "100px Arial";
ctx.fillStyle = "red";
ctx.fillText("Ciao!",0,i);
};
setInterval(frame,10);
document.body.appendChild(canvas);