console
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
* {margin: 0;padding: 0;}
#wrap {
width: 300px;
height: 300px;
margin: 50px auto 0;
}
</style>
</head>
<body>
<div id="wrap">
<svg id='svg' xmlns="http://www.w3.org/2000/svg" width='100%' height='100%'>
</svg>
</div>
<script>
let svg = document.getElementById('svg');
function creatTagEle(tag, tagAttr) {
let svgNS = "http://www.w3.org/2000/svg";
let oTag = document.createElementNS(svgNS, tag)
for (let attr in tagAttr) {
oTag.setAttribute(attr, tagAttr[attr])
}
return oTag;
}
function move(num, color, time) {
let nowTime = new Date();
let outR = 120;
let inneR = 70;
let centerX = 150;
let centerY = 150;
let n = 0;
let timer = setInterval(function () {
let prop = (new Date() - nowTime) / time;
if (prop >= 1) {
prop = 1
clearInterval(timer)
}
let angleNum = 0;
let outXY = [{ x: 270, y: 150 }];
let inneXY = [{ x: 220, y: 150 }];
for (let i = 0; i < num.length; i++) {
let aNum = num[i] / 100 * 360;
angleNum += aNum;
if (i == num.length - 1) {angleNum = 360;}
let outX = Math.cos(angleNum * prop * Math.PI / 180) * outR + centerX;
let outY = Math.sin(angleNum * prop * Math.PI / 180) * outR + centerY;
outXY.push({ x: outX, y: outY })
let inneX = Math.cos(angleNum * prop * Math.PI / 180) * inneR + centerX;
let inneY = Math.sin(angleNum * prop * Math.PI / 180) * inneR + centerY;
inneXY.push({ x: inneX, y: inneY })
}
for (let i = 0; i < outXY.length - 1; i++) {
let oPath = creatTagEle('path', {
fill: color[i],
d: `M${outXY[i].x} ${outXY[i].y}A${outR} ${outR} 0 0 1 ${outXY[i + 1].x} ${outXY[i + 1].y}L${inneXY[i + 1].x} ${inneXY[i + 1].y}A${inneR} ${inneR} 0 0 0 ${inneXY[i].x} ${inneXY[i].y}`
});
svg.appendChild(oPath)
}
if(n++){
for(let i=0; i<num.length; i++){
svg.removeChild(svg.childNodes[1])
}
}
}, 1000 / 60);
}
move(
[15.5, 32.11, 22.22, 10, 13.14, 7.03],
["#24acf2", "#dd5044", "yellow", "orange", "#a83d34","purple"],
2000
)
</script>
</body>
</html>