@thi.ng/geom-clip-line 2.3.89 → 2.3.91
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/CHANGELOG.md +7 -1
- package/README.md +2 -2
- package/clip-poly.js +4 -4
- package/clip-with.d.ts +7 -3
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2024-
|
|
3
|
+
- **Last updated**: 2024-06-29T09:28:36Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -9,6 +9,12 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
### [2.3.90](https://github.com/thi-ng/umbrella/tree/@thi.ng/geom-clip-line@2.3.90) (2024-06-21)
|
|
13
|
+
|
|
14
|
+
#### ♻️ Refactoring
|
|
15
|
+
|
|
16
|
+
- enforce uniform naming convention of internal functions ([56992b2](https://github.com/thi-ng/umbrella/commit/56992b2))
|
|
17
|
+
|
|
12
18
|
### [2.3.86](https://github.com/thi-ng/umbrella/tree/@thi.ng/geom-clip-line@2.3.86) (2024-04-20)
|
|
13
19
|
|
|
14
20
|
#### ♻️ Refactoring
|
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 189 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
|
>
|
|
@@ -75,7 +75,7 @@ For Node.js REPL:
|
|
|
75
75
|
const gcl = await import("@thi.ng/geom-clip-line");
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
-
Package sizes (brotli'd, pre-treeshake): ESM:
|
|
78
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 762 bytes
|
|
79
79
|
|
|
80
80
|
## Dependencies
|
|
81
81
|
|
package/clip-poly.js
CHANGED
|
@@ -9,7 +9,7 @@ const clipLinePoly = (a, b, poly) => {
|
|
|
9
9
|
poly,
|
|
10
10
|
true
|
|
11
11
|
).isec;
|
|
12
|
-
return isecs ?
|
|
12
|
+
return isecs ? __collectSegments(isecs) : void 0;
|
|
13
13
|
};
|
|
14
14
|
const clipLineSegmentPoly = (a, b, poly) => {
|
|
15
15
|
const isecs = intersectLinePolylineAll(a, b, poly, true).isec;
|
|
@@ -20,7 +20,7 @@ const clipLineSegmentPoly = (a, b, poly) => {
|
|
|
20
20
|
}
|
|
21
21
|
isAInside && isecs.unshift(a);
|
|
22
22
|
isBInside && isecs.push(b);
|
|
23
|
-
return
|
|
23
|
+
return __collectSegments(isecs);
|
|
24
24
|
};
|
|
25
25
|
const clipPolylinePoly = (pts, poly) => {
|
|
26
26
|
let res = [];
|
|
@@ -39,7 +39,7 @@ const clipPolylinePoly = (pts, poly) => {
|
|
|
39
39
|
} else {
|
|
40
40
|
isAInside && isecs.unshift(a);
|
|
41
41
|
isBInside && isecs.push(b);
|
|
42
|
-
const [first, ...segments] =
|
|
42
|
+
const [first, ...segments] = __collectSegments(isecs);
|
|
43
43
|
if (isAInside) {
|
|
44
44
|
if (res.length) res[res.length - 1].push(first[1]);
|
|
45
45
|
else res.push(first);
|
|
@@ -52,7 +52,7 @@ const clipPolylinePoly = (pts, poly) => {
|
|
|
52
52
|
}
|
|
53
53
|
return res;
|
|
54
54
|
};
|
|
55
|
-
const
|
|
55
|
+
const __collectSegments = (isecs) => {
|
|
56
56
|
const segments = [];
|
|
57
57
|
for (let i = 0, n = isecs.length - 1; i < n; i += 2) {
|
|
58
58
|
segments.push([isecs[i], isecs[i + 1]]);
|
package/clip-with.d.ts
CHANGED
|
@@ -13,13 +13,15 @@ import type { ReadonlyVec } from "@thi.ng/vectors";
|
|
|
13
13
|
* other vertex, that entire chunk will be discarded.
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
16
|
-
* ```ts
|
|
16
|
+
* ```ts tangle:../export/clip-polyline-with.ts
|
|
17
17
|
* import { clipPolylineWith } from "@thi.ng/geom-clip-line";
|
|
18
18
|
*
|
|
19
19
|
* const pts = [[0, 0], [1, 0], [1, 1], [2, 1], [3, 1], [4, 0], [5, 0]];
|
|
20
20
|
*
|
|
21
21
|
* // isolate horizontal chunks
|
|
22
|
-
*
|
|
22
|
+
* console.log(
|
|
23
|
+
* clipPolylineWith((a, b) => a[1] == b[1], pts)
|
|
24
|
+
* );
|
|
23
25
|
* // [
|
|
24
26
|
* // [[0, 0], [1, 0]],
|
|
25
27
|
* // [[1, 1], [2, 1], [3, 1]],
|
|
@@ -27,7 +29,9 @@ import type { ReadonlyVec } from "@thi.ng/vectors";
|
|
|
27
29
|
* // ]
|
|
28
30
|
*
|
|
29
31
|
* // isolate sloped chunks
|
|
30
|
-
*
|
|
32
|
+
* console.log(
|
|
33
|
+
* clipPolylineWith((a, b) => a[1] != b[1], pts)
|
|
34
|
+
* );
|
|
31
35
|
* // [
|
|
32
36
|
* // [[1, 0], [1, 1]],
|
|
33
37
|
* // [[3, 1], [4, 0]]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/geom-clip-line",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.91",
|
|
4
4
|
"description": "2D line clipping (Liang-Barsky)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "https://github.com/thi-ng/umbrella.git"
|
|
12
12
|
},
|
|
13
|
-
"homepage": "https://
|
|
13
|
+
"homepage": "https://thi.ng/geom-clip-line",
|
|
14
14
|
"funding": [
|
|
15
15
|
{
|
|
16
16
|
"type": "github",
|
|
@@ -36,15 +36,15 @@
|
|
|
36
36
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@thi.ng/api": "^8.11.
|
|
40
|
-
"@thi.ng/geom-isec": "^
|
|
41
|
-
"@thi.ng/vectors": "^7.
|
|
39
|
+
"@thi.ng/api": "^8.11.4",
|
|
40
|
+
"@thi.ng/geom-isec": "^4.0.1",
|
|
41
|
+
"@thi.ng/vectors": "^7.11.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@microsoft/api-extractor": "^7.
|
|
45
|
-
"esbuild": "^0.21.
|
|
44
|
+
"@microsoft/api-extractor": "^7.47.0",
|
|
45
|
+
"esbuild": "^0.21.5",
|
|
46
46
|
"typedoc": "^0.25.13",
|
|
47
|
-
"typescript": "^5.
|
|
47
|
+
"typescript": "^5.5.2"
|
|
48
48
|
},
|
|
49
49
|
"keywords": [
|
|
50
50
|
"2d",
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
],
|
|
88
88
|
"year": 2013
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "7b950c112fba0b2e7c450765b15624c3382f1354\n"
|
|
91
91
|
}
|