Mirror labels with their symbols instead of counter-mirroring

Labels now follow the mirrored shape naturally — text mirrors
along with the conveyor/shape as the user expects.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
igurielidze 2026-03-30 21:11:01 +04:00
parent 533465be3c
commit c69d4080fa
2 changed files with 4 additions and 8 deletions

View File

@ -573,8 +573,7 @@ function drawConveyanceLabel(ctx: CanvasRenderingContext2D, sym: PlacedSymbol) {
// - Counter-mirror if symbol is mirrored (so text doesn't read backwards) // - Counter-mirror if symbol is mirrored (so text doesn't read backwards)
const rot = ((sym.rotation || 0) % 360 + 360) % 360; const rot = ((sym.rotation || 0) % 360 + 360) % 360;
const needsFlip = rot > 90 && rot < 270; const needsFlip = rot > 90 && rot < 270;
const needsMirrorFix = sym.mirrored; const hasCorrection = needsFlip;
const hasCorrection = needsFlip || needsMirrorFix;
ctx.fillStyle = '#000000'; ctx.fillStyle = '#000000';
ctx.textAlign = 'center'; ctx.textAlign = 'center';
@ -603,7 +602,6 @@ function drawConveyanceLabel(ctx: CanvasRenderingContext2D, sym: PlacedSymbol) {
ctx.save(); ctx.save();
ctx.translate(cx, cy); ctx.translate(cx, cy);
if (needsFlip) ctx.rotate(Math.PI); if (needsFlip) ctx.rotate(Math.PI);
if (needsMirrorFix) ctx.scale(-1, 1);
for (let i = 0; i < tryLines.length; i++) { for (let i = 0; i < tryLines.length; i++) {
const dy = -(lineCount - 1) * lineH / 2 + i * lineH; const dy = -(lineCount - 1) * lineH / 2 + i * lineH;
ctx.fillText(tryLines[i], 0, dy); ctx.fillText(tryLines[i], 0, dy);
@ -643,8 +641,7 @@ function drawCurvedLabel(ctx: CanvasRenderingContext2D, sym: PlacedSymbol) {
if (worldAngle > Math.PI / 2 && worldAngle < Math.PI * 3 / 2) { if (worldAngle > Math.PI / 2 && worldAngle < Math.PI * 3 / 2) {
textRot += Math.PI; textRot += Math.PI;
} }
// Handle mirror // Mirror: label follows the mirrored shape naturally
if (sym.mirrored) textRot = -textRot;
const availW = bandW - 4; const availW = bandW - 4;

View File

@ -40,7 +40,7 @@ function emitConveyanceLabelInner(lines: string[], sym: PlacedSymbol) {
let worldAngle = (textRotRad + symRotRad) % (2 * Math.PI); let worldAngle = (textRotRad + symRotRad) % (2 * Math.PI);
if (worldAngle < 0) worldAngle += 2 * Math.PI; if (worldAngle < 0) worldAngle += 2 * Math.PI;
if (worldAngle > Math.PI / 2 && worldAngle < Math.PI * 3 / 2) textRotRad += Math.PI; if (worldAngle > Math.PI / 2 && worldAngle < Math.PI * 3 / 2) textRotRad += Math.PI;
if (sym.mirrored) textRotRad = -textRotRad; // 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)) {
const w2 = sym.w2 ?? sym.w; const w2 = sym.w2 ?? sym.w;
@ -63,8 +63,7 @@ function emitConveyanceLabelInner(lines: string[], sym: PlacedSymbol) {
if (!isCurvedType(sym.symbolId)) { if (!isCurvedType(sym.symbolId)) {
const rot = ((sym.rotation || 0) % 360 + 360) % 360; const rot = ((sym.rotation || 0) % 360 + 360) % 360;
if (rot > 90 && rot < 270) textRotDeg = 180; if (rot > 90 && rot < 270) textRotDeg = 180;
// Mirror fix: text inside group inherits mirror, counter it // Mirror: label follows mirrored shape naturally (inside group)
if (sym.mirrored && textRotDeg === 0) textRotDeg = 0; // mirrored handled by scale in group
} }
const fontSize = Math.min(14, availH / textLines.length); const fontSize = Math.min(14, availH / textLines.length);