Spur label: position at 75% height in the wide bottom portion

Center text at 75% of trapezoid height where the shape is widest,
using the actual width at that height for proper fit.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
igurielidze 2026-03-30 21:32:23 +04:00
parent 762e65e9a6
commit 3adbfffb9d
2 changed files with 11 additions and 10 deletions

View File

@ -556,12 +556,13 @@ 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;
// Center text at the wide end of the trapezoid // Center in the wider half of the trapezoid (bottom half where w > w2)
const wideEnd = Math.max(w2, sym.w); // At 75% height, width = w2 + 0.75*(w-w2) = w2*0.25 + w*0.75
cx = sym.x + wideEnd / 2; const widthAt75 = w2 * 0.25 + sym.w * 0.75;
cy = sym.y + sym.h / 2; cx = sym.x + widthAt75 / 2;
availW = wideEnd - pad * 2; cy = sym.y + sym.h * 0.75;
availH = sym.h - pad * 2; availW = widthAt75 - pad * 2;
availH = sym.h * 0.45;
} else { } else {
cx = sym.x + sym.w / 2; cx = sym.x + sym.w / 2;
cy = sym.y + sym.h / 2; cy = sym.y + sym.h / 2;

View File

@ -44,10 +44,10 @@ 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 wideEnd = Math.max(w2, sym.w); const widthAt75 = w2 * 0.25 + sym.w * 0.75;
labelCx = sym.x + wideEnd / 2; labelCx = sym.x + widthAt75 / 2;
labelCy = sym.y + sym.h / 2; labelCy = sym.y + sym.h * 0.75;
availH = sym.h - 4; availH = sym.h * 0.45;
} else if (isInductionType(sym.symbolId)) { } else if (isInductionType(sym.symbolId)) {
const stripTopY = sym.y + sym.h * INDUCTION_CONFIG.stripTopFrac; const stripTopY = sym.y + sym.h * INDUCTION_CONFIG.stripTopFrac;
const stripBottomY = sym.y + sym.h * INDUCTION_CONFIG.stripBottomFrac; const stripBottomY = sym.y + sym.h * INDUCTION_CONFIG.stripBottomFrac;