From 4fce9d80f7dbd123b277ef3f1bb4ca9bd8467f12 Mon Sep 17 00:00:00 2001 From: Caleb Hearon Date: Mon, 20 Jan 2025 21:49:06 -0500 Subject: [PATCH] messed up borders in svg painter not sure if these were ever tested? --- src/paint-svg.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/paint-svg.ts b/src/paint-svg.ts index 693358e..9c9a68c 100644 --- a/src/paint-svg.ts +++ b/src/paint-svg.ts @@ -76,13 +76,17 @@ export default class HtmlPaintBackend implements PaintBackend { edge(x: number, y: number, length: number, side: 'top' | 'right' | 'bottom' | 'left') { const {r, g, b, a} = this.strokeColor; - const sw = this.lineWidth; - const width = side === 'top' || side === 'bottom' ? length + 'px' : sw + 'px'; - const height = side === 'left' || side === 'right' ? length + 'px' : sw + 'px'; + const lw = this.lineWidth; + const lw2 = lw / 2; + const width = side === 'top' || side === 'bottom' ? length : lw; + const height = side === 'left' || side === 'right' ? length : lw; const backgroundColor = `rgba(${r}, ${g}, ${b}, ${a})`; const rect = this.clips.at(-1); const clipPath = rect ? `clip-path="url(#${rect.id}) "` : ' '; + x = side === 'left' || side === 'right' ? x - lw2 : x; + y = side === 'top' || side === 'bottom' ? y - lw2 : y; + this.main += ``; }