基本上我希望能够使用画布填充圆形,但它像饼图和蒙版一样动画,以便在圆圈中显示新图像。 我的画布知识并不奇妙,这是一张图片来展示我想要的东西。 任何人都会谈到如何做到这一点? 这里是我所管理使用画布动画像饼图一样填充圆形
var canvas = document.getElementById('Circle');
var context = canvas.getContext('2d');
var centerX = canvas.width/2;
var centerY = canvas.height/2;
var radius = 80;
var full = radius*2;
var amount = 0;
var amountToIncrease = 0.1;
function draw() {
context.beginPath();
context.arc(centerX, centerY, radius, 0, amount * Math.PI, false);
context.fillStyle = '#13a8a4';
context.fill();
context.lineWidth = 10;
context.strokeStyle = '#000000';
context.stroke();
amount += amountToIncrease;
if (amount > full) amount = 0; // restart
}
draw();
// Every second we'll fill more;
setInterval(draw, 100);
您可以选择坊间的作为答案的答复,这是可以正常使用。 – nottinhill