1 回答
TA贡献1784条经验 获得超7个赞
let canvas = document.getElementById('canvas'),
degree = 0,
countD = ['3', '2', '1', "Go!"],
count = 0;
canvas.height = 344;
canvas.width = 344;
let c = canvas.getContext('2d');
let degreeToRadian = function(degree){
return (degree*22)/(180*7);
}
let animate = function(){
if(count<3){
requestAnimationFrame(animate);
}
c.clearRect(0, 0, canvas.width, canvas.height);
c.beginPath();
/* border alignment*/
c.arc(170, 170, 150, degreeToRadian(-90), degreeToRadian(degree));
c.shadowBlur = 15;
c.shadowColor = "red";
c.strokeStyle="white";
c.lineWidth = 10;
c.stroke();
c.beginPath();
/* Text alignment */
c.strokeText(countD[count], 170, 215);
c.lineWidth = 0;
c.font = "120px NeonTubes2Regular";
c.textAlign = "center";
c.fillText("test data....",10,50);
c.stroke();
degree+=4;
if(degree === 360){
degree = 0;
count++;
}
}
animate();
添加回答
举报