Fix spur label sizing: use narrow end width so text fits inside trapezoid
Position text at 40% from top (toward narrow end) and constrain width to the narrower edge so text never overflows the trapezoid shape. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
3506d6164d
commit
072c80e886
@ -556,10 +556,13 @@ 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;
|
||||
const midW = (w2 + sym.w) / 2; // width at vertical midpoint
|
||||
cx = sym.x + midW / 2;
|
||||
cy = sym.y + sym.h / 2;
|
||||
availW = midW - pad * 2;
|
||||
// Use the width at 40% from top (biased toward narrow end for safe fit)
|
||||
const t = 0.4;
|
||||
const widthAtT = w2 + t * (sym.w - w2);
|
||||
cx = sym.x + widthAtT / 2;
|
||||
cy = sym.y + sym.h * t;
|
||||
// Use narrower of top/bottom edge with padding for safe text fit
|
||||
availW = Math.min(w2, widthAtT) - pad * 2;
|
||||
availH = sym.h - pad * 2;
|
||||
} else {
|
||||
cx = sym.x + sym.w / 2;
|
||||
|
||||
@ -44,9 +44,11 @@ function emitConveyanceLabelInner(lines: string[], sym: PlacedSymbol) {
|
||||
textRotDeg = (textRotRad * 180) / Math.PI;
|
||||
} else if (isSpurType(sym.symbolId)) {
|
||||
const w2 = sym.w2 ?? sym.w;
|
||||
labelCx = sym.x + (w2 + sym.w) / 4;
|
||||
labelCy = sym.y + sym.h / 2;
|
||||
availH = sym.h - 4;
|
||||
const t = 0.4;
|
||||
const widthAtT = w2 + t * (sym.w - w2);
|
||||
labelCx = sym.x + widthAtT / 2;
|
||||
labelCy = sym.y + sym.h * t;
|
||||
availH = Math.min(sym.h - 4, widthAtT - 4);
|
||||
} else if (isInductionType(sym.symbolId)) {
|
||||
const stripTopY = sym.y + sym.h * INDUCTION_CONFIG.stripTopFrac;
|
||||
const stripBottomY = sym.y + sym.h * INDUCTION_CONFIG.stripBottomFrac;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user