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:
parent
dba857bcc6
commit
9fe6172161
@ -556,11 +556,12 @@ 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 right-angle corner (w, h) where the most space is.
|
// The 90° corners are at x=0 (left edge). The rectangular region
|
||||||
// The right edge at mid-height is at (w2+w)/2. Shift further right.
|
// from x=0 to x=min(w2,w) always fits inside the trapezoid.
|
||||||
cx = sym.x + sym.w * 0.65;
|
const safeW = Math.min(w2, sym.w);
|
||||||
cy = sym.y + sym.h * 0.65;
|
cx = sym.x + safeW / 2;
|
||||||
availW = sym.w;
|
cy = sym.y + sym.h / 2;
|
||||||
|
availW = safeW;
|
||||||
availH = sym.h;
|
availH = sym.h;
|
||||||
} else {
|
} else {
|
||||||
cx = sym.x + sym.w / 2;
|
cx = sym.x + sym.w / 2;
|
||||||
|
|||||||
@ -43,8 +43,10 @@ function emitConveyanceLabelInner(lines: string[], sym: PlacedSymbol) {
|
|||||||
// Mirror: label follows the mirrored shape naturally
|
// Mirror: label follows the mirrored shape naturally
|
||||||
textRotDeg = (textRotRad * 180) / Math.PI;
|
textRotDeg = (textRotRad * 180) / Math.PI;
|
||||||
} else if (isSpurType(sym.symbolId)) {
|
} else if (isSpurType(sym.symbolId)) {
|
||||||
labelCx = sym.x + sym.w * 0.65;
|
const w2 = sym.w2 ?? sym.w;
|
||||||
labelCy = sym.y + sym.h * 0.65;
|
const safeW = Math.min(w2, sym.w);
|
||||||
|
labelCx = sym.x + safeW / 2;
|
||||||
|
labelCy = sym.y + sym.h / 2;
|
||||||
availH = sym.h;
|
availH = sym.h;
|
||||||
} 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;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user