Spur label: position at 90-degree side (x=0 to x=w2 rectangle)

The 90-degree corners are at x=0 in local coords. The rectangular
region from x=0 to x=min(w2,w) always fits inside the trapezoid.
Text is centered in this safe zone — on the straight-edge side,
not the angled side.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
igurielidze 2026-03-30 21:38:41 +04:00
parent dba857bcc6
commit 9fe6172161
2 changed files with 10 additions and 7 deletions

View File

@ -556,11 +556,12 @@ 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;
// Center text at the right-angle corner (w, h) where the most space is.
// The right edge at mid-height is at (w2+w)/2. Shift further right.
cx = sym.x + sym.w * 0.65;
cy = sym.y + sym.h * 0.65;
availW = sym.w;
// The 90° corners are at x=0 (left edge). The rectangular region
// from x=0 to x=min(w2,w) always fits inside the trapezoid.
const safeW = Math.min(w2, sym.w);
cx = sym.x + safeW / 2;
cy = sym.y + sym.h / 2;
availW = safeW;
availH = sym.h;
} else {
cx = sym.x + sym.w / 2;

View File

@ -43,8 +43,10 @@ function emitConveyanceLabelInner(lines: string[], sym: PlacedSymbol) {
// Mirror: label follows the mirrored shape naturally
textRotDeg = (textRotRad * 180) / Math.PI;
} else if (isSpurType(sym.symbolId)) {
labelCx = sym.x + sym.w * 0.65;
labelCy = sym.y + sym.h * 0.65;
const w2 = sym.w2 ?? sym.w;
const safeW = Math.min(w2, sym.w);
labelCx = sym.x + safeW / 2;
labelCy = sym.y + sym.h / 2;
availH = sym.h;
} else if (isInductionType(sym.symbolId)) {
const stripTopY = sym.y + sym.h * INDUCTION_CONFIG.stripTopFrac;