[153][77] Strichmuster: geschlossene Züge (Rechtecke, Vielecke, Ellipsen) über den Umfang gestreckt in Plan-/Druck-SVG, Szene, React-SVG, DXF/DWG (plinegen); Zauberstab: e2e-Test

This commit is contained in:
Claude committed 2026-11-11 14:51:45 +00:00
1 parent b9202f7da3
commit 652c50bc52
16 files changed
+298 -49

No files matched your search

+7 -6
View File
@@ -305,26 +305,27 @@ function appendStroke(
// [153] Vollkreis (Zug, dessen Ende am Anfang liegt): Muster auf ganze Wiederholungen gestreckt, die Naht
// schliesst; keine Phase noetig.
const ring = closed || isRing(mm);
const useDash = !closed && ring ? ringDash(mm, dash) : dash;
const useDash = ring ? ringDash(mm, dash, closed) : dash;
el.setAttribute("stroke-dasharray", useDash.map((d) => round(d)).join(" "));
// Punkte (Strich 0) brauchen runde Enden, sonst unsichtbar ([96]).
if (useDash.some((d) => d === 0)) el.setAttribute("stroke-linecap", "round");
if (closed || !ring) setDashOffset(el, mm, closed, dash);
if (!ring) setDashOffset(el, mm, closed, dash);
}
svg.appendChild(el);
}
/** Offener Zug mit Ende auf dem Anfang (tesselierter Vollkreis der Szene, mindestens 8 Punkte). */
/** Offener Zug mit Ende auf dem Anfang (tesselierter Kreis/Ellipse, Rechteck der Szene, mindestens 4 Punkte). */
function isRing(ptsMm: [number, number][]): boolean {
const n = ptsMm.length;
if (n < 8) return false;
if (n < 4) return false;
return Math.hypot(ptsMm[n - 1][0] - ptsMm[0][0], ptsMm[n - 1][1] - ptsMm[0][1]) < 1e-6;
}
/** [153] Muster des Rings auf ganze Wiederholungen über seine Länge gestreckt (Kern `plan::line_pattern::fit_closed`). */
function ringDash(ptsMm: [number, number][], dash: number[]): number[] {
function ringDash(ptsMm: [number, number][], dash: number[], closed: boolean): number[] {
let len = 0;
for (let i = 0; i + 1 < ptsMm.length; i++) len += Math.hypot(ptsMm[i + 1][0] - ptsMm[i][0], ptsMm[i + 1][1] - ptsMm[i][1]);
const n = ptsMm.length;
for (let i = 0; i + 1 < n + (closed ? 1 : 0); i++) len += Math.hypot(ptsMm[(i + 1) % n][0] - ptsMm[i][0], ptsMm[(i + 1) % n][1] - ptsMm[i][1]);
return Array.from(core().line_dash_fit_closed(len, Float64Array.from(dash)));
}
@@ -1,13 +1,13 @@
viewBox -41.5 0 95 63.6
bytes 65479
bytes 65308
circle 16
g 1
line 143
path 35
polygon 87
polyline 107
polygon 92
polyline 102
rect 1
svg 1
text 115
tspan 24
hash cdf3c4d888a4598e
hash e66ad56c29e492f4
@@ -1,13 +1,13 @@
viewBox -41.5 0 95 63.6
bytes 107203
bytes 107022
circle 16
g 1
line 371
path 66
polygon 208
polyline 125
polygon 213
polyline 120
rect 1
svg 1
text 115
tspan 24
hash 20219a2968028509
hash d35f938c9f8e6157
@@ -1,5 +1,5 @@
viewBox -13.448 0 38.615 33.813
bytes 45537
bytes 45473
circle 14
g 1
line 116
@@ -10,4 +10,4 @@ rect 1
svg 1
text 87
tspan 19
hash 4979f090d722b180
hash cfea6b6c1949a5de
@@ -1,5 +1,5 @@
viewBox -12.974 0 37.808 33.406
bytes 354349
bytes 354278
circle 14
g 1
line 3259
@@ -10,4 +10,4 @@ rect 1
svg 1
text 86
tspan 18
hash 341559a934122255
hash d07966afd213a683
@@ -1,10 +1,10 @@
viewBox -1.621 0 8.242 7.763
bytes 2669
bytes 2638
g 1
line 2
polygon 12
polyline 3
polygon 13
polyline 2
rect 1
svg 1
text 3
hash d0fc9efc7b012bf2
hash bf1a2d46506512f4
@@ -1,10 +1,10 @@
viewBox -1.56 0 8.121 7.581
bytes 4552
bytes 4518
g 1
line 2
polygon 29
polyline 3
polygon 30
polyline 2
rect 1
svg 1
text 3
hash db41c17fef99a859
hash f90a323318f1a1e6
+3 -1
View File
@@ -421,8 +421,10 @@ export function DrawingRunShape({
const scrPts = modelPts.map(toScreen);
const pts = scrPts.map((s) => `${s.x},${s.y}`).join(" ");
const plotN = paperScale ?? 100;
// [153] Ring = geschlossener Zug (Rechteck, Vieleck, Ellipse, Kreis; Ende = Anfang): Muster über den Umfang gestreckt.
const ring =
!run.closed && scrPts.length >= 8 && Math.hypot(scrPts[scrPts.length - 1].x - scrPts[0].x, scrPts[scrPts.length - 1].y - scrPts[0].y) < 1e-6;
run.closed ||
(scrPts.length >= 4 && Math.hypot(scrPts[scrPts.length - 1].x - scrPts[0].x, scrPts[scrPts.length - 1].y - scrPts[0].y) < 1e-6);
const dashStr =
run.dash && run.dash.length
? dashArrayCss(ring ? ringDashVb(run.dash, plotN, runLen(scrPts)) : lineDashVb(run.dash, plotN), !print)