From 4277a0ca488071ce77f30006a4bc4f1be7b472bc Mon Sep 17 00:00:00 2001 From: Thibaud Date: Tue, 17 Feb 2026 20:18:11 +0100 Subject: [PATCH] fix: smooth shape animation Avoid using Math.trunc with caused stepping effect in animations --- client.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client.ts b/client.ts index 1a37f37..5eea1d8 100644 --- a/client.ts +++ b/client.ts @@ -85,7 +85,7 @@ function drawAnimatedCircle(ctx: CanvasRenderingContext2D, dt: number, x: number ctx.save(); ctx.beginPath(); ctx.arc(x, y, radius, 0, Math.min(end, 2*Math.PI)); - const percent = Math.trunc(100*Math.min(end, 2*Math.PI)/(2*Math.PI)); + const percent = Math.floor(100*Math.min(end, 2*Math.PI)/(2*Math.PI)); ctx.strokeStyle = `hsla(${hue}, ${percent}%, 50%, 1)`; ctx.lineWidth = 5; ctx.stroke(); @@ -112,7 +112,7 @@ function drawAnimatedCross(ctx: CanvasRenderingContext2D, dt: number, x: number, } ctx.lineWidth = 5; - const percent = Math.trunc(100*Math.min(delta, SHAPE_SIZE)/SHAPE_SIZE); + const percent = Math.floor(100*Math.min(delta, SHAPE_SIZE)/SHAPE_SIZE); ctx.strokeStyle = `hsla(${hue}, ${percent}%, 50%, 1)`; ctx.stroke(); ctx.restore();