@thi.ng/geom 8.3.7 → 8.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/api/complex-polygon.js +1 -1
- package/api/path.js +2 -2
- package/api/path3.js +2 -2
- package/as-path.js +1 -1
- package/clip-convex.js +3 -3
- package/closest-point.js +3 -3
- package/flip.js +1 -1
- package/intersects.js +1 -1
- package/package.json +29 -29
- package/path-from-cubics.js +1 -1
- package/tessellate.js +1 -1
- package/vertices.js +2 -2
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://mastodon.thi.ng/@toxi)
|
|
8
8
|
|
|
9
9
|
> [!NOTE]
|
|
10
|
-
> This is one of
|
|
10
|
+
> This is one of 211 standalone projects, maintained as part
|
|
11
11
|
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
|
|
12
12
|
> and anti-framework.
|
|
13
13
|
>
|
package/api/complex-polygon.js
CHANGED
package/api/path.js
CHANGED
|
@@ -55,7 +55,7 @@ class Path {
|
|
|
55
55
|
return !!this.subPaths.length;
|
|
56
56
|
}
|
|
57
57
|
addSegments(...segments) {
|
|
58
|
-
for (
|
|
58
|
+
for (const s of segments) {
|
|
59
59
|
this.closed && illegalState("path already closed");
|
|
60
60
|
this.segments.push(s);
|
|
61
61
|
}
|
|
@@ -82,7 +82,7 @@ class Path {
|
|
|
82
82
|
if (this.segments.length > 1) {
|
|
83
83
|
$hiccupSegments(this.segments);
|
|
84
84
|
}
|
|
85
|
-
for (
|
|
85
|
+
for (const p of this.subPaths) $hiccupSegments(p);
|
|
86
86
|
return ["path", this.attribs || {}, acc];
|
|
87
87
|
}
|
|
88
88
|
}
|
package/api/path3.js
CHANGED
|
@@ -55,7 +55,7 @@ class Path3 {
|
|
|
55
55
|
return !!this.subPaths.length;
|
|
56
56
|
}
|
|
57
57
|
addSegments(...segments) {
|
|
58
|
-
for (
|
|
58
|
+
for (const s of segments) {
|
|
59
59
|
this.closed && illegalState("path already closed");
|
|
60
60
|
this.segments.push(s);
|
|
61
61
|
}
|
|
@@ -82,7 +82,7 @@ class Path3 {
|
|
|
82
82
|
if (this.segments.length > 1) {
|
|
83
83
|
$hiccupSegments(this.segments);
|
|
84
84
|
}
|
|
85
|
-
for (
|
|
85
|
+
for (const p of this.subPaths) $hiccupSegments(p);
|
|
86
86
|
return ["path3", this.attribs || {}, acc];
|
|
87
87
|
}
|
|
88
88
|
}
|
package/as-path.js
CHANGED
package/clip-convex.js
CHANGED
|
@@ -43,7 +43,7 @@ const clipConvex = defmulti(
|
|
|
43
43
|
);
|
|
44
44
|
if (!clipped.length) return void 0;
|
|
45
45
|
const res = [new Polygon(clipped)];
|
|
46
|
-
for (
|
|
46
|
+
for (const child of $.children) {
|
|
47
47
|
clipped = sutherlandHodgeman(child.points, boundary, c);
|
|
48
48
|
if (clipped.length) res.push(new Polygon(clipped));
|
|
49
49
|
}
|
|
@@ -59,7 +59,7 @@ const clipConvex = defmulti(
|
|
|
59
59
|
group: ({ children, attribs }, boundary) => {
|
|
60
60
|
boundary = ensureVertices(boundary);
|
|
61
61
|
const clipped = [];
|
|
62
|
-
for (
|
|
62
|
+
for (const c of children) {
|
|
63
63
|
const res = clipConvex(c, boundary);
|
|
64
64
|
if (res) clipped.push(...res);
|
|
65
65
|
}
|
|
@@ -90,7 +90,7 @@ const clipConvex = defmulti(
|
|
|
90
90
|
[],
|
|
91
91
|
__copyAttribs($.attribs)
|
|
92
92
|
);
|
|
93
|
-
for (
|
|
93
|
+
for (const sub of $.subPaths) {
|
|
94
94
|
clipped = __clipVertices(
|
|
95
95
|
new Path(sub, [], __copyAttribs($.attribs)),
|
|
96
96
|
boundary
|
package/closest-point.js
CHANGED
|
@@ -33,7 +33,7 @@ const closestPoint = defmulti(
|
|
|
33
33
|
out = closestPointPolyline(p, $.boundary.points, true, out);
|
|
34
34
|
let minD = distSq2(p, out);
|
|
35
35
|
let tmp = [];
|
|
36
|
-
for (
|
|
36
|
+
for (const child of $.children) {
|
|
37
37
|
closestPointPolyline(p, child.points, true, tmp);
|
|
38
38
|
const d = distSq2(p, tmp);
|
|
39
39
|
if (d < minD) {
|
|
@@ -55,7 +55,7 @@ const closestPoint = defmulti(
|
|
|
55
55
|
path: ($, p, out) => {
|
|
56
56
|
let minD = Infinity;
|
|
57
57
|
const $closestPSegment = (segments) => {
|
|
58
|
-
for (
|
|
58
|
+
for (const s of segments) {
|
|
59
59
|
if (!s.geo) continue;
|
|
60
60
|
const q = closestPoint(s.geo, p);
|
|
61
61
|
if (!q) continue;
|
|
@@ -67,7 +67,7 @@ const closestPoint = defmulti(
|
|
|
67
67
|
}
|
|
68
68
|
};
|
|
69
69
|
$closestPSegment($.segments);
|
|
70
|
-
for (
|
|
70
|
+
for (const sub of $.subPaths) $closestPSegment(sub);
|
|
71
71
|
return out;
|
|
72
72
|
},
|
|
73
73
|
plane: ($, p, out) => closestPointPlane(p, $.normal, $.w, out),
|
package/flip.js
CHANGED
package/intersects.js
CHANGED
|
@@ -66,7 +66,7 @@ const intersects = defmulti(
|
|
|
66
66
|
const points = [];
|
|
67
67
|
const all = opts?.all;
|
|
68
68
|
let inside = false;
|
|
69
|
-
for (
|
|
69
|
+
for (const child of children) {
|
|
70
70
|
let $res = intersects(ray, child, opts);
|
|
71
71
|
if ($res.type !== IntersectionType.INTERSECT) continue;
|
|
72
72
|
if ($res.inside) inside = true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/geom",
|
|
3
|
-
"version": "8.3.
|
|
3
|
+
"version": "8.3.9",
|
|
4
4
|
"description": "Functional, polymorphic API for 2D geometry types & SVG generation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -40,33 +40,33 @@
|
|
|
40
40
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@thi.ng/adjacency": "^3.0.
|
|
44
|
-
"@thi.ng/api": "^8.12.
|
|
45
|
-
"@thi.ng/arrays": "^2.14.
|
|
46
|
-
"@thi.ng/checks": "^3.
|
|
47
|
-
"@thi.ng/defmulti": "^3.0.
|
|
48
|
-
"@thi.ng/equiv": "^2.1.
|
|
49
|
-
"@thi.ng/errors": "^2.5.
|
|
50
|
-
"@thi.ng/geom-arc": "^2.1.
|
|
51
|
-
"@thi.ng/geom-clip-line": "^2.3.
|
|
52
|
-
"@thi.ng/geom-clip-poly": "^2.1.
|
|
53
|
-
"@thi.ng/geom-closest-point": "^2.1.
|
|
54
|
-
"@thi.ng/geom-hull": "^2.1.
|
|
55
|
-
"@thi.ng/geom-isec": "^4.0.
|
|
56
|
-
"@thi.ng/geom-poly-utils": "^3.1.
|
|
57
|
-
"@thi.ng/geom-resample": "^3.0.
|
|
58
|
-
"@thi.ng/geom-splines": "^2.3.
|
|
59
|
-
"@thi.ng/geom-subdiv-curve": "^3.0.
|
|
60
|
-
"@thi.ng/geom-tessellate": "^3.0.
|
|
61
|
-
"@thi.ng/hiccup": "^5.3.
|
|
62
|
-
"@thi.ng/hiccup-svg": "^5.5.
|
|
63
|
-
"@thi.ng/math": "^5.
|
|
64
|
-
"@thi.ng/matrices": "^3.0.
|
|
65
|
-
"@thi.ng/object-utils": "^1.3.
|
|
66
|
-
"@thi.ng/random": "^4.1.
|
|
67
|
-
"@thi.ng/strings": "^3.9.
|
|
68
|
-
"@thi.ng/transducers": "^9.6.
|
|
69
|
-
"@thi.ng/vectors": "^8.6.
|
|
43
|
+
"@thi.ng/adjacency": "^3.0.64",
|
|
44
|
+
"@thi.ng/api": "^8.12.10",
|
|
45
|
+
"@thi.ng/arrays": "^2.14.3",
|
|
46
|
+
"@thi.ng/checks": "^3.8.0",
|
|
47
|
+
"@thi.ng/defmulti": "^3.0.86",
|
|
48
|
+
"@thi.ng/equiv": "^2.1.100",
|
|
49
|
+
"@thi.ng/errors": "^2.5.50",
|
|
50
|
+
"@thi.ng/geom-arc": "^2.1.204",
|
|
51
|
+
"@thi.ng/geom-clip-line": "^2.3.161",
|
|
52
|
+
"@thi.ng/geom-clip-poly": "^2.1.203",
|
|
53
|
+
"@thi.ng/geom-closest-point": "^2.1.199",
|
|
54
|
+
"@thi.ng/geom-hull": "^2.1.199",
|
|
55
|
+
"@thi.ng/geom-isec": "^4.0.71",
|
|
56
|
+
"@thi.ng/geom-poly-utils": "^3.1.8",
|
|
57
|
+
"@thi.ng/geom-resample": "^3.0.71",
|
|
58
|
+
"@thi.ng/geom-splines": "^2.3.71",
|
|
59
|
+
"@thi.ng/geom-subdiv-curve": "^3.0.78",
|
|
60
|
+
"@thi.ng/geom-tessellate": "^3.0.78",
|
|
61
|
+
"@thi.ng/hiccup": "^5.3.33",
|
|
62
|
+
"@thi.ng/hiccup-svg": "^5.5.20",
|
|
63
|
+
"@thi.ng/math": "^5.14.0",
|
|
64
|
+
"@thi.ng/matrices": "^3.0.30",
|
|
65
|
+
"@thi.ng/object-utils": "^1.3.2",
|
|
66
|
+
"@thi.ng/random": "^4.1.35",
|
|
67
|
+
"@thi.ng/strings": "^3.9.31",
|
|
68
|
+
"@thi.ng/transducers": "^9.6.19",
|
|
69
|
+
"@thi.ng/vectors": "^8.6.15"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"esbuild": "^0.27.0",
|
|
@@ -533,5 +533,5 @@
|
|
|
533
533
|
"tag": "geometry",
|
|
534
534
|
"year": 2013
|
|
535
535
|
},
|
|
536
|
-
"gitHead": "
|
|
536
|
+
"gitHead": "824bf9047b5a10f777c5c5b4aeecf0c750a22c75\n"
|
|
537
537
|
}
|
package/path-from-cubics.js
CHANGED
|
@@ -18,7 +18,7 @@ const __pathFromCubics = (ctor, cubics, attribs) => {
|
|
|
18
18
|
curr = [{ type: "m", point: c.points[0] }];
|
|
19
19
|
subPaths.push(curr);
|
|
20
20
|
};
|
|
21
|
-
for (
|
|
21
|
+
for (const c of cubics) {
|
|
22
22
|
if (!(lastP && equals(lastP, c.points[0]))) $beginPath(c);
|
|
23
23
|
curr.push({ type: "c", geo: c });
|
|
24
24
|
lastP = c.points[3];
|
package/tessellate.js
CHANGED
|
@@ -46,7 +46,7 @@ const tessellate = defmulti(
|
|
|
46
46
|
group: ($, fns, tess) => {
|
|
47
47
|
fns = ensureArray(fns);
|
|
48
48
|
tess = tess || new BasicTessellation();
|
|
49
|
-
for (
|
|
49
|
+
for (const child of $.children) {
|
|
50
50
|
tess = tessellate(child, fns, tess);
|
|
51
51
|
}
|
|
52
52
|
return tess;
|
package/vertices.js
CHANGED
|
@@ -89,7 +89,7 @@ const vertices = defmulti(
|
|
|
89
89
|
},
|
|
90
90
|
complexpoly: ($, opts) => {
|
|
91
91
|
const pts = vertices($.boundary, opts);
|
|
92
|
-
for (
|
|
92
|
+
for (const child of $.children) pts.push(...vertices(child, opts));
|
|
93
93
|
return pts;
|
|
94
94
|
},
|
|
95
95
|
cubic: ($, opts) => sampleCubic($.points, __sampleAttribs(opts, $.attribs)),
|
|
@@ -135,7 +135,7 @@ const vertices = defmulti(
|
|
|
135
135
|
}
|
|
136
136
|
};
|
|
137
137
|
$segmentVerts($.segments);
|
|
138
|
-
for (
|
|
138
|
+
for (const sub of $.subPaths) $segmentVerts(sub);
|
|
139
139
|
return verts;
|
|
140
140
|
},
|
|
141
141
|
points: ($) => $.points.slice(),
|