【发布时间】:2016-05-21 12:49:19
【问题描述】:
基本上我希望能够使用画布填充一个圆圈,但它像饼图和蒙版一样动画以在圆圈中显示新图像。 我的画布知识并不惊人,这是一个显示我想要的图像。 有人对如何做到这一点有所了解吗? 这是我管理的一个小提琴
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);
【问题讨论】:
-
你可以选择markE的回复作为答案,效果很好。
标签: javascript html canvas