[109] [101] Schraffuren: Generator als eigenes Crate (hatchgen), render3d-Live-Schnitt/Druck-SVG/SVG-PlanView zeichnen Schichtmuster mit dem Kern-Generator, Putz/Keramik/Faserzement mit Schraffur (Punktfeld), Standards aktualisieren im Ressourcen-Manager
This commit is contained in:
38 files changed
+1004
-74
No files matched your search
@@ -10,7 +10,7 @@
|
||||
*/
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { polyUsesPattern } from "./primitives";
|
||||
import { isGeneratedPattern, polyUsesPattern } from "./primitives";
|
||||
import type { HatchRender } from "../../../plan/generatePlan/shared";
|
||||
|
||||
function hatch(over: Partial<HatchRender> = {}): HatchRender {
|
||||
@@ -43,3 +43,14 @@ describe("polyUsesPattern — gradient", () => {
|
||||
expect(polyUsesPattern(hatch({ pattern: "none" }))).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("polyUsesPattern — Kern-Generator-Muster ([109])", () => {
|
||||
it("Schicht-/Streumuster laufen über buildHatchRuns, nicht über <pattern>-Kacheln", () => {
|
||||
for (const pattern of ["insulation", "insulationHard", "insulationWave", "timber", "earth", "gravel", "stone", "dots"] as const) {
|
||||
expect(isGeneratedPattern(pattern)).toBe(true);
|
||||
expect(polyUsesPattern(hatch({ pattern }))).toBe(false);
|
||||
}
|
||||
expect(polyUsesPattern(hatch({ pattern: "diagonal" }))).toBe(true);
|
||||
expect(polyUsesPattern(hatch({ pattern: "crosshatch" }))).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -8,7 +8,7 @@ import { NO_HATCH } from "../../../core";
|
||||
import { layoutText, stampBlockLines, wrapPlainText } from "../../../text/renderHtml";
|
||||
import type { Vec2 } from "../../../model/types";
|
||||
import { quantizePen } from "../../../export/sceneToPrintSvg";
|
||||
import { buildRandomHatchRuns, zigzagPoints, motifPoints, DASH_MM_TO_M } from "../../../core";
|
||||
import { buildHatchRuns, buildRandomHatchRuns, zigzagPoints, motifPoints, DASH_MM_TO_M } from "../../../core";
|
||||
import { dashHasDot } from "../../../core";
|
||||
import { HAIRLINE_PX, PX_PER_M, mmToPx, printStrokeVb, visibleEdgeRuns } from "../../../core";
|
||||
import { dashArrayCss, fitDashToPeriod, hatchDashVb, lineDashVb } from "../../../core";
|
||||
@@ -19,13 +19,30 @@ const IMG_TILE_VB = 40;
|
||||
/** Lineare/Kreuz-Muster brauchen ein <pattern>; solid/none nicht. */
|
||||
export function needsPattern(pattern: HatchRender["pattern"]): boolean {
|
||||
return (
|
||||
pattern === "insulation" ||
|
||||
pattern === "diagonal" ||
|
||||
pattern === "crosshatch" ||
|
||||
pattern === "custom"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Muster, die der Kern-Generator als Linien/Polylinien erzeugt ([109]: Dämmschlange, Zickzack, Welle, Holzkreuz,
|
||||
* Naturstein, Erdreich, Kies, Punktfeld) — der SVG-Rückfall zeichnet sie wie GL/Druck-SVG aus
|
||||
* `buildHatchRuns` (eine Implementierung) statt als `<pattern>`-Kachel.
|
||||
*/
|
||||
export function isGeneratedPattern(pattern: HatchRender["pattern"]): boolean {
|
||||
return (
|
||||
pattern === "insulation" ||
|
||||
pattern === "insulationHard" ||
|
||||
pattern === "insulationWave" ||
|
||||
pattern === "timber" ||
|
||||
pattern === "earth" ||
|
||||
pattern === "gravel" ||
|
||||
pattern === "stone" ||
|
||||
pattern === "dots"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ob ein Polygon einen SVG-Fill-Server aus `<defs>` braucht (`<pattern>` ODER
|
||||
* `<linearGradient>`/`<radialGradient>` — beide lassen sich identisch per
|
||||
@@ -40,6 +57,7 @@ export function polyUsesPattern(h: HatchRender): boolean {
|
||||
if (h.kind === "image") return !!h.image;
|
||||
if (h.kind === "gradient") return !!h.gradient;
|
||||
if (h.lines === "random") return false;
|
||||
if (isGeneratedPattern(h.pattern)) return false;
|
||||
return needsPattern(h.pattern);
|
||||
}
|
||||
|
||||
@@ -122,37 +140,6 @@ export function HatchPattern({
|
||||
);
|
||||
}
|
||||
|
||||
if (hatch.pattern === "insulation") {
|
||||
// Weiche Zickzack-/Wellenlinie (SIA-nah). Kachel 14×10 × Maßstab.
|
||||
const w = 14 * hatch.scale;
|
||||
const h = 10 * hatch.scale;
|
||||
const my = 5 * hatch.scale;
|
||||
const qy1 = -1 * hatch.scale;
|
||||
const qy2 = 11 * hatch.scale;
|
||||
const qx1 = 3.5 * hatch.scale;
|
||||
const qx2 = 7 * hatch.scale;
|
||||
const qx3 = 10.5 * hatch.scale;
|
||||
return (
|
||||
<pattern
|
||||
id={id}
|
||||
patternUnits="userSpaceOnUse"
|
||||
width={w}
|
||||
height={h}
|
||||
patternTransform={`rotate(${hatch.angle})`}
|
||||
>
|
||||
<path
|
||||
d={`M0 ${my} Q ${qx1} ${qy1} ${qx2} ${my} Q ${qx3} ${qy2} ${w} ${my}`}
|
||||
fill="none"
|
||||
stroke={hatch.color}
|
||||
strokeWidth={sw}
|
||||
style={dashStyle(w)}
|
||||
strokeLinecap={dashCap}
|
||||
vectorEffect={vfx}
|
||||
/>
|
||||
</pattern>
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
hatch.pattern === "custom" &&
|
||||
hatch.motif &&
|
||||
@@ -570,9 +557,9 @@ export function renderPrimitive(
|
||||
// Random-Vektor-Schraffur (Kies/Splitt): Grundfüllung + deterministische
|
||||
// Streu-Striche (im MODELL-Raum erzeugt → toScreen; identischer Seed wie
|
||||
// GL/PDF) + Umriss. KEIN <pattern> (die Striche werden direkt gezeichnet).
|
||||
if (p.hatch.kind !== "image" && p.hatch.lines === "random") {
|
||||
if (p.hatch.kind !== "image" && (p.hatch.lines === "random" || isGeneratedPattern(p.hatch.pattern))) {
|
||||
const hsw = weight(p.hatch.lineWeight > 0 ? p.hatch.lineWeight : 0.13);
|
||||
const runs = buildRandomHatchRuns(p.pts, p.hatch);
|
||||
const runs = p.hatch.lines === "random" ? buildRandomHatchRuns(p.pts, p.hatch) : buildHatchRuns(p.pts, p.hatch);
|
||||
return (
|
||||
<g>
|
||||
<polygon points={pts} fill={p.fill} stroke="none" />
|
||||
|
||||
Reference in new issue
Block a user