Here is my question: I have an animation that builds a circle. See: http://jsfiddle.net/2TUnE/
JavaScript:
var currentEndAngle = 0
var currentStartAngle = 0;
var currentColor = 'black';
setInterval(draw, 50);
function draw() {
var can = document.getElementById('canvas1');
var canvas = document.getElementById("canvas1");
var context = canvas.getContext("2d");
var x = canvas.width / 2;
var y = canvas.height / 2;
var radius = 75;
var startAngle = currentStartAngle * Math.PI;
var endAngle = (currentEndAngle) * Math.PI;
currentEndAngle = currentEndAngle + 0.01;
var counterClockwise = false;
context.beginPath();
context.arc(x, y, radius, startAngle, endAngle, counterClockwise);
context.lineWidth = 15;
context.strokeStyle = currentColor;
context.stroke();
}
When the circle is completely drawn, I would like it to start to fade, just as it was created (it removes black so slowly). As soon as the whole circle is erased, I will again create a black circle, creating the effect of "waiting / loading".
What I tried to do is check if currentEndAngle is 2 (so the circle is complete), then move startAngle, but it doesn't work.
Any idea?
Thank!
EDIT: Forgot to say the animation will be above the image, so it should be "transparent", not white.
source
share