From f6a491e83bab9481a2cac3367541a3b7803df9ab Mon Sep 17 00:00:00 2001 From: Dariusz L Date: Sat, 28 Jun 2025 19:56:13 +0200 Subject: [PATCH] Adjust text background height and padding in CanvasRenderer Refines the calculation of text background height and vertical padding for multi-line text rendering, ensuring more consistent spacing and alignment. --- js/CanvasRenderer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/CanvasRenderer.js b/js/CanvasRenderer.js index 58bde37..2fcaafe 100644 --- a/js/CanvasRenderer.js +++ b/js/CanvasRenderer.js @@ -235,14 +235,14 @@ export class CanvasRenderer { const textMetrics = lines.map(line => ctx.measureText(line)); const textBgWidth = Math.max(...textMetrics.map(m => m.width)) + 10; const lineHeight = 18; - const textBgHeight = lines.length * lineHeight + (lines.length > 1 ? 5 : 0) + 10; + const textBgHeight = lines.length * lineHeight + 4; ctx.fillStyle = "rgba(0, 0, 0, 0.7)"; ctx.fillRect(screenX - textBgWidth / 2, screenY - textBgHeight / 2, textBgWidth, textBgHeight); ctx.fillStyle = "white"; lines.forEach((line, index) => { - const yPos = screenY - (textBgHeight / 2) + (lineHeight / 2) + (index * lineHeight) + 5; + const yPos = screenY - (textBgHeight / 2) + (lineHeight / 2) + (index * lineHeight) + 2; ctx.fillText(line, screenX, yPos); });