From 762e65e9a68a3af669161cf6c5504bcec6c07beb Mon Sep 17 00:00:00 2001 From: igurielidze Date: Mon, 30 Mar 2026 21:31:35 +0400 Subject: [PATCH] Spur label: center at the wide end of the trapezoid Co-Authored-By: Claude Opus 4.6 (1M context) --- svelte-app/src/lib/canvas/renderer.ts | 11 ++++------- svelte-app/src/lib/export.ts | 4 ++-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/svelte-app/src/lib/canvas/renderer.ts b/svelte-app/src/lib/canvas/renderer.ts index 1c177de..44cdcfb 100644 --- a/svelte-app/src/lib/canvas/renderer.ts +++ b/svelte-app/src/lib/canvas/renderer.ts @@ -556,14 +556,11 @@ function drawConveyanceLabel(ctx: CanvasRenderingContext2D, sym: PlacedSymbol) { let cx: number, cy: number, availW: number, availH: number; if (isSpurType(sym.symbolId)) { const w2 = sym.w2 ?? sym.w; - // Spur trapezoid: top edge = w2, bottom edge = w, left edge vertical. - // At vertical center, right edge is at (w2+w)/2. - // Place text centered in the wider rectangular region. - const midRightEdge = (w2 + sym.w) / 2; - // Use inner 70% of that width, shifted right (toward wide end) - cx = sym.x + midRightEdge * 0.55; + // Center text at the wide end of the trapezoid + const wideEnd = Math.max(w2, sym.w); + cx = sym.x + wideEnd / 2; cy = sym.y + sym.h / 2; - availW = midRightEdge * 0.85 - pad * 2; + availW = wideEnd - pad * 2; availH = sym.h - pad * 2; } else { cx = sym.x + sym.w / 2; diff --git a/svelte-app/src/lib/export.ts b/svelte-app/src/lib/export.ts index 511f35f..8fde604 100644 --- a/svelte-app/src/lib/export.ts +++ b/svelte-app/src/lib/export.ts @@ -44,8 +44,8 @@ function emitConveyanceLabelInner(lines: string[], sym: PlacedSymbol) { textRotDeg = (textRotRad * 180) / Math.PI; } else if (isSpurType(sym.symbolId)) { const w2 = sym.w2 ?? sym.w; - const midRightEdge = (w2 + sym.w) / 2; - labelCx = sym.x + midRightEdge * 0.55; + const wideEnd = Math.max(w2, sym.w); + labelCx = sym.x + wideEnd / 2; labelCy = sym.y + sym.h / 2; availH = sym.h - 4; } else if (isInductionType(sym.symbolId)) {