From 35aa0bf7dc1e02fcb317164408e8124f591eb73a Mon Sep 17 00:00:00 2001 From: igurielidze Date: Mon, 30 Mar 2026 21:31:11 +0400 Subject: [PATCH] Position spur label in the wider area of the trapezoid Center text at vertical midpoint, shifted right toward the wider end where there's more horizontal space. Uses 55% of the mid-height width as center position and 85% as available width. Co-Authored-By: Claude Opus 4.6 (1M context) --- svelte-app/src/lib/canvas/renderer.ts | 14 ++++++++------ svelte-app/src/lib/export.ts | 7 +++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/svelte-app/src/lib/canvas/renderer.ts b/svelte-app/src/lib/canvas/renderer.ts index ecb8648..1c177de 100644 --- a/svelte-app/src/lib/canvas/renderer.ts +++ b/svelte-app/src/lib/canvas/renderer.ts @@ -556,12 +556,14 @@ 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; - // Position text toward the wider end where there's more room - const t = 0.65; - const widthAtT = w2 + t * (sym.w - w2); - cx = sym.x + widthAtT / 2; - cy = sym.y + sym.h * t; - availW = widthAtT - pad * 2; + // 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; + cy = sym.y + sym.h / 2; + availW = midRightEdge * 0.85 - 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 5a6222f..511f35f 100644 --- a/svelte-app/src/lib/export.ts +++ b/svelte-app/src/lib/export.ts @@ -44,10 +44,9 @@ function emitConveyanceLabelInner(lines: string[], sym: PlacedSymbol) { textRotDeg = (textRotRad * 180) / Math.PI; } else if (isSpurType(sym.symbolId)) { const w2 = sym.w2 ?? sym.w; - const t = 0.65; - const widthAtT = w2 + t * (sym.w - w2); - labelCx = sym.x + widthAtT / 2; - labelCy = sym.y + sym.h * t; + const midRightEdge = (w2 + sym.w) / 2; + labelCx = sym.x + midRightEdge * 0.55; + labelCy = sym.y + sym.h / 2; availH = sym.h - 4; } else if (isInductionType(sym.symbolId)) { const stripTopY = sym.y + sym.h * INDUCTION_CONFIG.stripTopFrac;