Open Yang03 opened 3 years ago
const canvasRef = useRef();
const drawCircle = (ctx, color, percent) => { ctx.beginPath(); ctx.lineCap = 'round'; ctx.strokeStyle = color; ctx.lineWidth = 8; ctx.arc(150, 75, 70, Math.PI 0, Math.PI percent, 0); ctx.stroke(); ctx.closePath(); };
const drawPercent = (ctx, percent = 1) => { // let max = nowSteps / userTarget + 1 // max = max >= 2 ? 2 : max const timer = setInterval(() => { if (percent < 1.5) { percent += 0.01; // drawCircle(ctx, '#ffa62b', 2); drawCircle(ctx, '#fff', percent); // this.ctx.draw() } else { clearInterval(timer); } }, 1000 / 60); };