JSFiddle - React, Tailwind, and code Playground
HTML
<canvas id="radius" width="110" height="110">
CSS
#con{width:210px; height:210px;}
JavaScript
var ctx = document.getElementById('radius').getContext('2d');
//画笔设置
ctx.strokeStyle = "rgba(216,216,216,100)";
ctx.lineWidth = "5";
ctx.lineCap = 'round';
//画星星
var img = new Image();
img.src="star.png";
img.onload = function(){
ctx.drawImage(img, 40, 40, 28, 28);
};
//灰色圆环
ctx.beginPath();
ctx.arc(55, 55, 50, 65 * Math.PI / 180, 115 * Math.PI / 180, true);
ctx.stroke();
ctx.closePath();
//白色圆环
drawArc(.8, ctx, "2/24");
//根据角度比例画圆弧,和奖杯个数
function drawArc(ratio, ctx, text){
//设置
ctx.strokeStyle = "rgba(255,255,255,100)";
var startAngle = 115 * Math.PI / 180;
var endAngle = (115 + 310 * ratio) * Math.PI / 180;
ctx.beginPath();
ctx.arc(55, 55, 50, startAngle, endAngle, false);
ctx.stroke();
ctx.closePath();
var myText = ctx.measureText(text);
ctx.fillStyle = 'rgba(255,255,255,100)';
ctx.font = "12px Microsoft YaHei";
ctx.fillText(text, (110 - myText.width)/2 - 2, 105);
}