Umschlag-Empfänger (mit Absender): Mindestabstand rechts für den Plotter
All checks were successful
Build & Deploy / deploy (push) Successful in 13s

Der Empfänger-Adressblock (Kuvert mit Absender) hielt rechts nur ~8 mm Abstand –
der Plotter braucht mehr Greiffläche. Startpunkt leicht nach links (0.55) und
Textbreite so begrenzt, dass rechts RAND_RECHTS_MM (15 mm) frei bleiben. Dieselbe
Konstante nutzt jetzt auch das Postkarten-Layout.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
s4luorth
2026-09-11 14:15:45 +02:00
parent 8030d3d0ec
commit 3399cece23

View File

@@ -18,6 +18,10 @@ const {
const SIG_CANVAS_W = 600;
const SIG_CANVAS_H = 160;
// Mindestabstand des Adressblocks zum rechten Rand (mm). Der Plotter braucht rechts
// Greiffläche – gilt einheitlich für Postkarte UND Umschlag-Empfänger (mit Absender).
const RAND_RECHTS_MM = 15;
/**
* Extrahiert Path- und Polyline-Elemente aus einem SVG-String und gibt sie als
* umgeformte <g>-Gruppe zurück, die an Position (x, y) mit Skalierung scale eingebettet ist.
@@ -297,7 +301,12 @@ function generateEnvelopeSVG(text, format, type, options = {}) {
// type === 'recipient' / 'free'. Ist ein Absender gesetzt, sitzt der
// Empfänger UNTEN RECHTS (klassisches Kuvert), sonst wie bisher oben links.
const hatAbsender = !!String(options.sender || '').trim();
const maxWidthPx = Math.min(widthPx - marginLeftPx - 20, widthPx * (hatAbsender ? 0.36 : 0.6));
// Empfänger unten rechts (mit Absender): Startpunkt zuerst festlegen, dann die
// Textbreite so begrenzen, dass rechts der Plotter-Mindestabstand frei bleibt.
const startXEmpf = Math.round(widthPx * 0.55);
const maxWidthPx = hatAbsender
? Math.max(mmToPx(30), (widthPx - mmToPx(RAND_RECHTS_MM)) - startXEmpf)
: Math.min(widthPx - marginLeftPx - 20, widthPx * 0.6);
lines = wrapTextToLinesByWidth({
text: String(text || ''),
@@ -309,7 +318,7 @@ function generateEnvelopeSVG(text, format, type, options = {}) {
if (hatAbsender) {
// Empfänger unten rechts – bewusst über Höhen-/Breiten-Anteile, damit der
// große Kuvert-Rand (marginTop bis ~50 % der Höhe) nicht alles nach oben zieht.
startX = Math.round(widthPx * 0.60);
startX = startXEmpf;
const untenBaseline = heightPx * 0.80; // unterste Zeile ~20 % über der Unterkante
startY = Math.round(untenBaseline - Math.max(0, lines.length - 1) * lineHeightPx);
} else {
@@ -452,7 +461,7 @@ function generatePostcardSVG(text, format, options = {}) {
const textRight = widthPx * 0.48;
const textWidth = Math.max(mmToPx(30), textRight - textLeft);
const addrLeft = widthPx * 0.52;
const addrRight = widthPx - mmToPx(8);
const addrRight = widthPx - mmToPx(RAND_RECHTS_MM);
const addrWidth = Math.max(mmToPx(30), addrRight - addrLeft);
const stampW = mmToPx(25);
const stampX = widthPx - mmToPx(6) - stampW;