Spaces:
Runtime error
Runtime error
Khunndev Cursor commited on
Commit ·
fa9c7b9
1
Parent(s): ddec551
Show count numbers inside circles from start of animation
Browse files
frontend/src/components/ResultCanvas.tsx
CHANGED
|
@@ -74,15 +74,16 @@ function drawCircle(
|
|
| 74 |
ctx.lineCap = 'round'
|
| 75 |
ctx.stroke()
|
| 76 |
|
| 77 |
-
// number label
|
| 78 |
-
if (
|
| 79 |
const fs = Math.max(9, Math.min(radius * 0.85, 15))
|
|
|
|
| 80 |
ctx.font = `bold ${fs}px sans-serif`
|
| 81 |
ctx.textAlign = 'center'
|
| 82 |
ctx.textBaseline = 'middle'
|
| 83 |
-
ctx.fillStyle =
|
| 84 |
ctx.fillText(label, cx + 0.6, cy + 0.6)
|
| 85 |
-
ctx.fillStyle =
|
| 86 |
ctx.fillText(label, cx, cy)
|
| 87 |
}
|
| 88 |
|
|
|
|
| 74 |
ctx.lineCap = 'round'
|
| 75 |
ctx.stroke()
|
| 76 |
|
| 77 |
+
// number label — shown as soon as circle begins drawing, fades in with fill
|
| 78 |
+
if (showLabel && radius >= 7 && eased > 0) {
|
| 79 |
const fs = Math.max(9, Math.min(radius * 0.85, 15))
|
| 80 |
+
const alpha = Math.min(1, eased * 2) // fade in during first half of animation
|
| 81 |
ctx.font = `bold ${fs}px sans-serif`
|
| 82 |
ctx.textAlign = 'center'
|
| 83 |
ctx.textBaseline = 'middle'
|
| 84 |
+
ctx.fillStyle = `rgba(0,0,0,${0.55 * alpha})`
|
| 85 |
ctx.fillText(label, cx + 0.6, cy + 0.6)
|
| 86 |
+
ctx.fillStyle = `rgba(255,255,255,${alpha})`
|
| 87 |
ctx.fillText(label, cx, cy)
|
| 88 |
}
|
| 89 |
|