Answer the question
In order to leave comments, you need to log in
How to make animation in canvas fade in?
Tell me what is my mistake?
It is not possible to make the alpha channel smoothly increase making the object visible.
When the function is called, you need to show the object, I try to implement it at intervals, it doesn’t work.
var canvas = document.getElementById('canvas').getContext('2d');
canvas.globalAlpha = 0;
function draw(){
canvas.fillRect(25,25,100,100);
canvas.clearRect(45,45,60,60);
canvas.strokeRect(50,50,50,50);
var i = 1;
setInterval(function(){
if(i <= 9){
i++;
canvas.globalAlpha = '0.' + i;
}
}, 50);
}
draw();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question