[146] Linienenden und -ecken einstellbar
Projekt-Einstellung lineCap/lineJoin (Standard flach + Gehrung, Grenze 4) in allen Ausgabewegen: render2d, Metal-Chunks (gpu_compile), Plan-SVG, Druck-SVG/PDF, React-SVG-Ansicht. Volle Einzel-Linien und Kantenläufe werden an gemeinsamen Enden zu Zügen genäht (keine Kerbe an Wandecken). UI in den Einstellungen (Projekt), Goldens neu.
This commit is contained in:
45 files changed
+558
-363
No files matched your search
@@ -28,6 +28,7 @@
|
||||
|
||||
import type { HatchRender, Plan } from "../plan/generatePlan";
|
||||
import { core } from "../engine/coreWasm";
|
||||
import { lineEndsSvgAttrs } from "../model/lineEnds";
|
||||
import { planParts, withPlanParts } from "../plan/planParts";
|
||||
|
||||
/** SVG-Namespace für die programmatisch erzeugten Knoten. */
|
||||
@@ -107,6 +108,8 @@ export interface PrintSvgOptions {
|
||||
bounds?: { minX: number; minY: number; maxX: number; maxY: number };
|
||||
/** Ohne weisses Blatt dahinter (als Schicht über anderem Inhalt). */
|
||||
transparent?: boolean;
|
||||
/** Linienenden und -ecken ([146], `cap | join << 2`); Standard `plan.lineEnds`. */
|
||||
lineEnds?: number;
|
||||
}
|
||||
|
||||
/** Modell-Meter → Papier-Millimeter im Massstab 1:N. */
|
||||
@@ -150,6 +153,9 @@ export function planToPrintSvg(plan: Plan, opts: PrintSvgOptions): PrintSvg {
|
||||
svg.setAttribute("width", String(opts.pageWidthMm));
|
||||
svg.setAttribute("height", String(opts.pageHeightMm));
|
||||
svg.setAttribute("viewBox", `0 0 ${opts.pageWidthMm} ${opts.pageHeightMm}`);
|
||||
// Linienenden und -ecken des Projekts ([146]): einmal am Wurzelelement, alle Striche erben sie
|
||||
// (der Kern setzt nur bei Punkt-Mustern eine eigene runde Kappe).
|
||||
for (const [k, v] of Object.entries(lineEndsSvgAttrs(opts.lineEnds ?? plan.lineEnds))) svg.setAttribute(k, v);
|
||||
|
||||
// Weisses Blatt (deckt die volle Seite).
|
||||
const bg = document.createElementNS(SVG_NS, "rect");
|
||||
|
||||
@@ -16,10 +16,12 @@ export interface SvgStringOptions {
|
||||
marginM?: number;
|
||||
/** Schraffurlinien ausbreiten (wie im Druck); Standard aus. */
|
||||
hatch?: boolean;
|
||||
/** Linienenden und -ecken ([146], `cap | join << 2`); Standard `plan.lineEnds`. */
|
||||
lineEnds?: number;
|
||||
}
|
||||
|
||||
export function planToSvgString(plan: Plan, opts: SvgStringOptions = {}): string {
|
||||
const b = plan.bounds;
|
||||
const o = Float64Array.from([opts.scaleDenominator ?? 100, opts.marginM ?? 0.5, b.minX, b.minY, b.maxX, b.maxY, ...(opts.hatch ? [1] : [])]);
|
||||
const o = Float64Array.from([opts.scaleDenominator ?? 100, opts.marginM ?? 0.5, b.minX, b.minY, b.maxX, b.maxY, opts.hatch ? 1 : 0, opts.lineEnds ?? plan.lineEnds ?? 0]);
|
||||
return withPlanParts(planParts(plan, true), (segs) => core().plan_svg_string(segs, o));
|
||||
}
|
||||
@@ -22,6 +22,7 @@
|
||||
//
|
||||
// Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md).
|
||||
|
||||
import { lineEndsSvgAttrs } from "../model/lineEnds";
|
||||
import type {
|
||||
RArc,
|
||||
RFill,
|
||||
@@ -134,6 +135,8 @@ export function sceneToPrintSvg(scene: RScene, opts: PrintSceneOptions): PrintSc
|
||||
svg.setAttribute("width", String(opts.pageWidthMm));
|
||||
svg.setAttribute("height", String(opts.pageHeightMm));
|
||||
svg.setAttribute("viewBox", `0 0 ${opts.pageWidthMm} ${opts.pageHeightMm}`);
|
||||
// Linienenden und -ecken des Projekts ([146]): einmal am Wurzelelement, alle Striche erben sie.
|
||||
for (const [k, v] of Object.entries(lineEndsSvgAttrs(scene.lineEnds))) svg.setAttribute(k, v);
|
||||
|
||||
const bg = document.createElementNS(SVG_NS, "rect");
|
||||
bg.setAttribute("x", "0");
|
||||
@@ -269,12 +272,12 @@ function appendStroke(
|
||||
el.setAttribute("stroke", rgbCss(color));
|
||||
setOpacityAttr(el, "stroke-opacity", color[3]);
|
||||
el.setAttribute("stroke-width", String(strokeMm));
|
||||
el.setAttribute("stroke-linejoin", "round");
|
||||
el.setAttribute("stroke-linecap", "round");
|
||||
if (dash && dash.length) {
|
||||
// Strichmuster ist bereits in Papier-mm definiert (siehe `toRenderScene.ts`:
|
||||
// „unveraendert durchgereicht"), also direkt uebernehmen.
|
||||
el.setAttribute("stroke-dasharray", dash.map((d) => round(d)).join(" "));
|
||||
// Punkte (Strich 0) brauchen runde Enden, sonst unsichtbar ([96]).
|
||||
if (dash.some((d) => d === 0)) el.setAttribute("stroke-linecap", "round");
|
||||
}
|
||||
svg.appendChild(el);
|
||||
}
|
||||
@@ -292,9 +295,9 @@ function appendLine(svg: SVGSVGElement, l: RLine, map: Mapper, _mmPerM: number):
|
||||
el.setAttribute("stroke", rgbCss(l.color));
|
||||
setOpacityAttr(el, "stroke-opacity", l.color[3]);
|
||||
el.setAttribute("stroke-width", String(quantizePen(l.widthMm)));
|
||||
el.setAttribute("stroke-linecap", "round");
|
||||
if (l.dash && l.dash.length) {
|
||||
el.setAttribute("stroke-dasharray", l.dash.map((d) => round(d)).join(" "));
|
||||
if (l.dash.some((d) => d === 0)) el.setAttribute("stroke-linecap", "round");
|
||||
}
|
||||
svg.appendChild(el);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user