Spur label: center at the wide end of the trapezoid

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
igurielidze 2026-03-30 21:31:35 +04:00
parent 35aa0bf7dc
commit 762e65e9a6
2 changed files with 6 additions and 9 deletions

View File

@ -556,14 +556,11 @@ function drawConveyanceLabel(ctx: CanvasRenderingContext2D, sym: PlacedSymbol) {
let cx: number, cy: number, availW: number, availH: number; let cx: number, cy: number, availW: number, availH: number;
if (isSpurType(sym.symbolId)) { if (isSpurType(sym.symbolId)) {
const w2 = sym.w2 ?? sym.w; const w2 = sym.w2 ?? sym.w;
// Spur trapezoid: top edge = w2, bottom edge = w, left edge vertical. // Center text at the wide end of the trapezoid
// At vertical center, right edge is at (w2+w)/2. const wideEnd = Math.max(w2, sym.w);
// Place text centered in the wider rectangular region. cx = sym.x + wideEnd / 2;
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; cy = sym.y + sym.h / 2;
availW = midRightEdge * 0.85 - pad * 2; availW = wideEnd - pad * 2;
availH = sym.h - pad * 2; availH = sym.h - pad * 2;
} else { } else {
cx = sym.x + sym.w / 2; cx = sym.x + sym.w / 2;

View File

@ -44,8 +44,8 @@ function emitConveyanceLabelInner(lines: string[], sym: PlacedSymbol) {
textRotDeg = (textRotRad * 180) / Math.PI; textRotDeg = (textRotRad * 180) / Math.PI;
} else if (isSpurType(sym.symbolId)) { } else if (isSpurType(sym.symbolId)) {
const w2 = sym.w2 ?? sym.w; const w2 = sym.w2 ?? sym.w;
const midRightEdge = (w2 + sym.w) / 2; const wideEnd = Math.max(w2, sym.w);
labelCx = sym.x + midRightEdge * 0.55; labelCx = sym.x + wideEnd / 2;
labelCy = sym.y + sym.h / 2; labelCy = sym.y + sym.h / 2;
availH = sym.h - 4; availH = sym.h - 4;
} else if (isInductionType(sym.symbolId)) { } else if (isInductionType(sym.symbolId)) {