@thi.ng/geom 3.1.7 → 3.2.2
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 +17 -1
- package/README.md +4 -3
- package/aabb.d.ts +2 -2
- package/aabb.js +2 -2
- package/api/bpatch.d.ts +38 -0
- package/api/bpatch.js +100 -0
- package/as-svg.d.ts +12 -0
- package/as-svg.js +22 -5
- package/bounds.js +5 -5
- package/bpatch.d.ts +7 -0
- package/bpatch.js +20 -0
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/internal/args.d.ts +3 -3
- package/internal/args.js +13 -5
- package/package.json +123 -115
- package/polygon.d.ts +1 -1
- package/rect.d.ts +2 -2
- package/rect.js +2 -2
- package/vertices.d.ts +1 -1
- package/vertices.js +2 -1
- package/warp-points.d.ts +4 -1
- package/warp-points.js +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**:
|
|
3
|
+
- **Last updated**: 2022-04-07T14:17:30Z
|
|
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,22 @@ 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
|
+
### [3.2.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/geom@3.2.1) (2022-04-07)
|
|
13
|
+
|
|
14
|
+
#### 🩹 Bug fixes
|
|
15
|
+
|
|
16
|
+
- fix [#336](https://github.com/thi-ng/umbrella/issues/336), update attrib ctor arg handling ([cb8e52a](https://github.com/thi-ng/umbrella/commit/cb8e52a))
|
|
17
|
+
- update internal __argAttribs() helper
|
|
18
|
+
- add tests
|
|
19
|
+
|
|
20
|
+
## [3.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/geom@3.2.0) (2022-03-11)
|
|
21
|
+
|
|
22
|
+
#### 🚀 Features
|
|
23
|
+
|
|
24
|
+
- update/refactor various shape ops ([0e3b99a](https://github.com/thi-ng/umbrella/commit/0e3b99a))
|
|
25
|
+
- add BPatch type, ctors and warp fn ([ea81cb5](https://github.com/thi-ng/umbrella/commit/ea81cb5))
|
|
26
|
+
- add opt. bleed attrib for `svgDoc()` ([fb3ed1e](https://github.com/thi-ng/umbrella/commit/fb3ed1e))
|
|
27
|
+
|
|
12
28
|
## [3.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/geom@3.1.0) (2021-11-17)
|
|
13
29
|
|
|
14
30
|
#### 🚀 Features
|
package/README.md
CHANGED
|
@@ -41,7 +41,7 @@ themselves too):
|
|
|
41
41
|
- [@thi.ng/geom-api](https://github.com/thi-ng/umbrella/tree/develop/packages/geom-api) - Shared type & interface declarations for [@thi.ng/geom](https://github.com/thi-ng/umbrella/tree/develop/packages/geom) packages
|
|
42
42
|
- [@thi.ng/geom-arc](https://github.com/thi-ng/umbrella/tree/develop/packages/geom-arc) - 2D circular / elliptic arc operations
|
|
43
43
|
- [@thi.ng/geom-clip-line](https://github.com/thi-ng/umbrella/tree/develop/packages/geom-clip-line) - 2D line clipping (Liang-Barsky)
|
|
44
|
-
- [@thi.ng/geom-clip-poly](https://github.com/thi-ng/umbrella/tree/develop/packages/geom-clip-poly) - 2D
|
|
44
|
+
- [@thi.ng/geom-clip-poly](https://github.com/thi-ng/umbrella/tree/develop/packages/geom-clip-poly) - 2D polygon clipping / offsetting (Sutherland-Hodgeman, Grainer-Hormann)
|
|
45
45
|
- [@thi.ng/geom-closest-point](https://github.com/thi-ng/umbrella/tree/develop/packages/geom-closest-point) - 2D / 3D closest point / proximity helpers
|
|
46
46
|
- [@thi.ng/geom-fuzz](https://github.com/thi-ng/umbrella/tree/develop/packages/geom-fuzz) - Highly configurable, fuzzy line & polygon creation with presets and composable fill & stroke styles. Canvas & SVG support
|
|
47
47
|
- [@thi.ng/geom-hull](https://github.com/thi-ng/umbrella/tree/develop/packages/geom-hull) - Fast 2D convex hull (Graham Scan)
|
|
@@ -84,12 +84,13 @@ node --experimental-repl-await
|
|
|
84
84
|
> const geom = await import("@thi.ng/geom");
|
|
85
85
|
```
|
|
86
86
|
|
|
87
|
-
Package sizes (gzipped, pre-treeshake): ESM:
|
|
87
|
+
Package sizes (gzipped, pre-treeshake): ESM: 12.44 KB
|
|
88
88
|
|
|
89
89
|
## Dependencies
|
|
90
90
|
|
|
91
91
|
- [@thi.ng/api](https://github.com/thi-ng/umbrella/tree/develop/packages/api)
|
|
92
92
|
- [@thi.ng/arrays](https://github.com/thi-ng/umbrella/tree/develop/packages/arrays)
|
|
93
|
+
- [@thi.ng/associative](https://github.com/thi-ng/umbrella/tree/develop/packages/associative)
|
|
93
94
|
- [@thi.ng/checks](https://github.com/thi-ng/umbrella/tree/develop/packages/checks)
|
|
94
95
|
- [@thi.ng/defmulti](https://github.com/thi-ng/umbrella/tree/develop/packages/defmulti)
|
|
95
96
|
- [@thi.ng/equiv](https://github.com/thi-ng/umbrella/tree/develop/packages/equiv)
|
|
@@ -165,4 +166,4 @@ If this project contributes to an academic publication, please cite it as:
|
|
|
165
166
|
|
|
166
167
|
## License
|
|
167
168
|
|
|
168
|
-
© 2013 -
|
|
169
|
+
© 2013 - 2022 Karsten Schmidt // Apache Software License 2.0
|
package/aabb.d.ts
CHANGED
|
@@ -10,8 +10,8 @@ export declare const aabbFromMinMax: (min: Vec, max: Vec, attribs?: Attribs | un
|
|
|
10
10
|
* Returns the intersection AABB of given inputs or `undefined` if they
|
|
11
11
|
* are non-overlapping.
|
|
12
12
|
*
|
|
13
|
-
* @param a
|
|
14
|
-
* @param b
|
|
13
|
+
* @param a -
|
|
14
|
+
* @param b -
|
|
15
15
|
*/
|
|
16
16
|
export declare const intersectionAABB: (a: AABB, b: AABB) => AABB | undefined;
|
|
17
17
|
/**
|
package/aabb.js
CHANGED
|
@@ -15,8 +15,8 @@ export const aabbFromMinMax = (min, max, attribs) => new AABB(min, sub3([], max,
|
|
|
15
15
|
* Returns the intersection AABB of given inputs or `undefined` if they
|
|
16
16
|
* are non-overlapping.
|
|
17
17
|
*
|
|
18
|
-
* @param a
|
|
19
|
-
* @param b
|
|
18
|
+
* @param a -
|
|
19
|
+
* @param b -
|
|
20
20
|
*/
|
|
21
21
|
export const intersectionAABB = (a, b) => {
|
|
22
22
|
const p = max3([], a.pos, b.pos);
|
package/api/bpatch.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Attribs, IHiccupShape } from "@thi.ng/geom-api";
|
|
2
|
+
import type { ReadonlyVec, Vec } from "@thi.ng/vectors";
|
|
3
|
+
import { APC } from "./apc.js";
|
|
4
|
+
/**
|
|
5
|
+
* nD Cubic bezier patch defined by array of 4x4 control points in this
|
|
6
|
+
* order:
|
|
7
|
+
*
|
|
8
|
+
* ```
|
|
9
|
+
* 7 11
|
|
10
|
+
* 3 +---+---+---+ 15 (UV = 1,1)
|
|
11
|
+
* | | | |
|
|
12
|
+
* 2 +---+---+---+ 14
|
|
13
|
+
* | | | |
|
|
14
|
+
* 1 +---+---+---+ 13
|
|
15
|
+
* v | | | |
|
|
16
|
+
* ^ 0 +---+---+---+ 12
|
|
17
|
+
* | 4 8
|
|
18
|
+
* |
|
|
19
|
+
* +----> u
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* The class implements a `unmapPoint()` method to transform a 2D UV coordinate
|
|
23
|
+
* into the worldspace position on the patch surface.
|
|
24
|
+
*
|
|
25
|
+
* The `toHiccup()` impl is only suitable for 2D patches.
|
|
26
|
+
*
|
|
27
|
+
* Ported from toxiclibs.
|
|
28
|
+
*
|
|
29
|
+
*/
|
|
30
|
+
export declare class BPatch extends APC implements IHiccupShape {
|
|
31
|
+
constructor(points: Vec[], attribs?: Attribs);
|
|
32
|
+
get type(): string;
|
|
33
|
+
copy(): BPatch;
|
|
34
|
+
edges(): Vec[][];
|
|
35
|
+
unmapPoint(uv: ReadonlyVec, out?: Vec): Vec;
|
|
36
|
+
toHiccup(): any[];
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=bpatch.d.ts.map
|
package/api/bpatch.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { assert } from "@thi.ng/errors/assert";
|
|
2
|
+
import { mixCubic } from "@thi.ng/vectors/mix-cubic";
|
|
3
|
+
import { __copyShape } from "../internal/copy.js";
|
|
4
|
+
import { APC } from "./apc.js";
|
|
5
|
+
/**
|
|
6
|
+
* nD Cubic bezier patch defined by array of 4x4 control points in this
|
|
7
|
+
* order:
|
|
8
|
+
*
|
|
9
|
+
* ```
|
|
10
|
+
* 7 11
|
|
11
|
+
* 3 +---+---+---+ 15 (UV = 1,1)
|
|
12
|
+
* | | | |
|
|
13
|
+
* 2 +---+---+---+ 14
|
|
14
|
+
* | | | |
|
|
15
|
+
* 1 +---+---+---+ 13
|
|
16
|
+
* v | | | |
|
|
17
|
+
* ^ 0 +---+---+---+ 12
|
|
18
|
+
* | 4 8
|
|
19
|
+
* |
|
|
20
|
+
* +----> u
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* The class implements a `unmapPoint()` method to transform a 2D UV coordinate
|
|
24
|
+
* into the worldspace position on the patch surface.
|
|
25
|
+
*
|
|
26
|
+
* The `toHiccup()` impl is only suitable for 2D patches.
|
|
27
|
+
*
|
|
28
|
+
* Ported from toxiclibs.
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
31
|
+
export class BPatch extends APC {
|
|
32
|
+
constructor(points, attribs) {
|
|
33
|
+
assert(points.length === 16, "require 16 control points");
|
|
34
|
+
super(points, attribs);
|
|
35
|
+
}
|
|
36
|
+
get type() {
|
|
37
|
+
return "bpatch";
|
|
38
|
+
}
|
|
39
|
+
copy() {
|
|
40
|
+
return __copyShape(BPatch, this);
|
|
41
|
+
}
|
|
42
|
+
edges() {
|
|
43
|
+
const p = this.points;
|
|
44
|
+
return [
|
|
45
|
+
[0, 1],
|
|
46
|
+
[1, 2],
|
|
47
|
+
[2, 3],
|
|
48
|
+
[0, 4],
|
|
49
|
+
[1, 5],
|
|
50
|
+
[2, 6],
|
|
51
|
+
[3, 7],
|
|
52
|
+
[4, 5],
|
|
53
|
+
[5, 6],
|
|
54
|
+
[6, 7],
|
|
55
|
+
[4, 8],
|
|
56
|
+
[5, 9],
|
|
57
|
+
[6, 10],
|
|
58
|
+
[7, 11],
|
|
59
|
+
[8, 9],
|
|
60
|
+
[9, 10],
|
|
61
|
+
[10, 11],
|
|
62
|
+
[8, 12],
|
|
63
|
+
[9, 13],
|
|
64
|
+
[10, 14],
|
|
65
|
+
[11, 15],
|
|
66
|
+
[12, 13],
|
|
67
|
+
[13, 14],
|
|
68
|
+
[14, 15],
|
|
69
|
+
].map(([a, b]) => [p[a], p[b]]);
|
|
70
|
+
}
|
|
71
|
+
unmapPoint(uv, out) {
|
|
72
|
+
const cp = this.points;
|
|
73
|
+
const [u, v] = uv;
|
|
74
|
+
return mixCubic(out || null, mixCubic([], cp[0], cp[4], cp[8], cp[12], v), mixCubic([], cp[1], cp[5], cp[9], cp[13], v), mixCubic([], cp[2], cp[6], cp[10], cp[14], v), mixCubic([], cp[3], cp[7], cp[11], cp[15], v), u);
|
|
75
|
+
}
|
|
76
|
+
toHiccup() {
|
|
77
|
+
const attribs = this.attribs;
|
|
78
|
+
const acc = ["g", { fill: "none", ...attribs }];
|
|
79
|
+
if (attribs && attribs.res) {
|
|
80
|
+
const res = attribs.res - 1;
|
|
81
|
+
const delta = 1 / res;
|
|
82
|
+
for (let u = 0; u <= res; u++) {
|
|
83
|
+
const col = [];
|
|
84
|
+
const row = [];
|
|
85
|
+
const uu = u * delta;
|
|
86
|
+
for (let v = 0; v <= res; v++) {
|
|
87
|
+
const p = [uu, v * delta];
|
|
88
|
+
col.push(this.unmapPoint(p));
|
|
89
|
+
row.push(this.unmapPoint([p[1], p[0]]));
|
|
90
|
+
}
|
|
91
|
+
acc.push(["polyline", {}, col]);
|
|
92
|
+
acc.push(["polyline", {}, row]);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
this.edges().forEach((l) => acc.push(["line", {}, ...l]));
|
|
97
|
+
}
|
|
98
|
+
return acc;
|
|
99
|
+
}
|
|
100
|
+
}
|
package/as-svg.d.ts
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import type { Attribs, IShape } from "@thi.ng/geom-api";
|
|
2
2
|
export declare const asSvg: (...args: any[]) => string;
|
|
3
|
+
/**
|
|
4
|
+
* Creates a hiccup SVG doc element for given {@link IShape}s and attribs. If
|
|
5
|
+
* the attribs do not include a `viewBox`, it will be computed automatically.
|
|
6
|
+
* Furthermore (and only for the case a viewbox needs to be computed), a `bleed`
|
|
7
|
+
* attrib can be provided to include a bleed/margin for the viewbox.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* Use {@link asSvg} to serialize the resulting doc to an SVG string.
|
|
11
|
+
*
|
|
12
|
+
* @param attribs
|
|
13
|
+
* @param xs
|
|
14
|
+
*/
|
|
3
15
|
export declare const svgDoc: (attribs: Attribs, ...xs: IShape[]) => any[];
|
|
4
16
|
//# sourceMappingURL=as-svg.d.ts.map
|
package/as-svg.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { withoutKeysObj } from "@thi.ng/associative/without-keys";
|
|
1
2
|
import { convertTree } from "@thi.ng/hiccup-svg/convert";
|
|
2
3
|
import { ff } from "@thi.ng/hiccup-svg/format";
|
|
3
4
|
import { svg } from "@thi.ng/hiccup-svg/svg";
|
|
@@ -5,17 +6,33 @@ import { serialize } from "@thi.ng/hiccup/serialize";
|
|
|
5
6
|
import { bounds } from "./bounds.js";
|
|
6
7
|
import { __collBounds } from "./internal/bounds.js";
|
|
7
8
|
export const asSvg = (...args) => args.map((x) => serialize(convertTree(x))).join("");
|
|
9
|
+
/**
|
|
10
|
+
* Creates a hiccup SVG doc element for given {@link IShape}s and attribs. If
|
|
11
|
+
* the attribs do not include a `viewBox`, it will be computed automatically.
|
|
12
|
+
* Furthermore (and only for the case a viewbox needs to be computed), a `bleed`
|
|
13
|
+
* attrib can be provided to include a bleed/margin for the viewbox.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* Use {@link asSvg} to serialize the resulting doc to an SVG string.
|
|
17
|
+
*
|
|
18
|
+
* @param attribs
|
|
19
|
+
* @param xs
|
|
20
|
+
*/
|
|
8
21
|
export const svgDoc = (attribs, ...xs) => {
|
|
9
22
|
if (xs.length > 0) {
|
|
10
|
-
if (!attribs
|
|
23
|
+
if (!attribs.viewBox) {
|
|
11
24
|
const cbounds = __collBounds(xs, bounds);
|
|
12
25
|
if (cbounds) {
|
|
13
26
|
const [[x, y], [w, h]] = cbounds;
|
|
27
|
+
const bleed = attribs.bleed || 0;
|
|
28
|
+
const bleed2 = 2 * bleed;
|
|
29
|
+
const width = ff(w + bleed2);
|
|
30
|
+
const height = ff(h + bleed2);
|
|
14
31
|
attribs = {
|
|
15
|
-
width
|
|
16
|
-
height
|
|
17
|
-
viewBox: `${ff(x)} ${ff(y)} ${
|
|
18
|
-
...attribs,
|
|
32
|
+
width,
|
|
33
|
+
height,
|
|
34
|
+
viewBox: `${ff(x - bleed)} ${ff(y - bleed)} ${width} ${height}`,
|
|
35
|
+
...withoutKeysObj(attribs, ["bleed"]),
|
|
19
36
|
};
|
|
20
37
|
}
|
|
21
38
|
}
|
package/bounds.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { defmulti } from "@thi.ng/defmulti/defmulti";
|
|
2
2
|
import { bounds as arcBounds } from "@thi.ng/geom-arc/bounds";
|
|
3
|
-
import {
|
|
3
|
+
import { bounds2, bounds3 } from "@thi.ng/geom-poly-utils/bounds";
|
|
4
4
|
import { cubicBounds } from "@thi.ng/geom-splines/cubic-bounds";
|
|
5
5
|
import { quadraticBounds } from "@thi.ng/geom-splines/quadratic-bounds";
|
|
6
6
|
import { comp } from "@thi.ng/transducers/comp";
|
|
7
7
|
import { filter } from "@thi.ng/transducers/filter";
|
|
8
8
|
import { iterator1 } from "@thi.ng/transducers/iterator";
|
|
9
9
|
import { map } from "@thi.ng/transducers/map";
|
|
10
|
-
import { MAX2, MAX3, MIN2, MIN3 } from "@thi.ng/vectors/api";
|
|
11
10
|
import { max } from "@thi.ng/vectors/max";
|
|
12
11
|
import { min } from "@thi.ng/vectors/min";
|
|
13
12
|
import { mul2 } from "@thi.ng/vectors/mul";
|
|
14
13
|
import { mulN2 } from "@thi.ng/vectors/muln";
|
|
15
|
-
import { set2
|
|
14
|
+
import { set2 } from "@thi.ng/vectors/set";
|
|
16
15
|
import { sub2 } from "@thi.ng/vectors/sub";
|
|
17
16
|
import { subN2 } from "@thi.ng/vectors/subn";
|
|
18
17
|
import { aabbFromMinMax } from "./aabb.js";
|
|
@@ -22,6 +21,7 @@ import { __dispatch } from "./internal/dispatch.js";
|
|
|
22
21
|
import { rectFromMinMax } from "./rect.js";
|
|
23
22
|
export const bounds = defmulti(__dispatch, {
|
|
24
23
|
aabb: "rect",
|
|
24
|
+
bpatch: "points",
|
|
25
25
|
poly: "points",
|
|
26
26
|
polyline: "points",
|
|
27
27
|
quad: "points",
|
|
@@ -42,8 +42,8 @@ export const bounds = defmulti(__dispatch, {
|
|
|
42
42
|
], bounds);
|
|
43
43
|
return b ? new Rect(...b) : undefined;
|
|
44
44
|
},
|
|
45
|
-
points: ($) => rectFromMinMax(...
|
|
46
|
-
points3: ($) => aabbFromMinMax(...
|
|
45
|
+
points: ($) => rectFromMinMax(...bounds2($.points)),
|
|
46
|
+
points3: ($) => aabbFromMinMax(...bounds3($.points)),
|
|
47
47
|
quadratic: ({ points }) => rectFromMinMax(...quadraticBounds(points[0], points[1], points[2])),
|
|
48
48
|
rect: ($) => $.copy(),
|
|
49
49
|
text: ($) => new Rect(set2([], $.pos), [0, 0]),
|
package/bpatch.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Attribs } from "@thi.ng/geom-api";
|
|
2
|
+
import { Vec } from "@thi.ng/vectors";
|
|
3
|
+
import { BPatch } from "./api/bpatch.js";
|
|
4
|
+
export declare const bpatch: (pts: Vec[], attribs?: Attribs | undefined) => BPatch;
|
|
5
|
+
export declare const bpatchFromQuad: (pts: Vec[], attribs?: Attribs | undefined) => BPatch;
|
|
6
|
+
export declare const bpatchFromHex: (pts: Vec[], attribs?: Attribs | undefined) => BPatch;
|
|
7
|
+
//# sourceMappingURL=bpatch.d.ts.map
|
package/bpatch.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { assert } from "@thi.ng/errors/assert";
|
|
2
|
+
import { mixBilinear } from "@thi.ng/vectors";
|
|
3
|
+
import { BPatch } from "./api/bpatch.js";
|
|
4
|
+
export const bpatch = (pts, attribs) => new BPatch(pts, attribs);
|
|
5
|
+
export const bpatchFromQuad = (pts, attribs) => {
|
|
6
|
+
assert(pts.length === 4, "require 4 points");
|
|
7
|
+
const [a, b, c, d] = pts;
|
|
8
|
+
const cps = [];
|
|
9
|
+
for (let u = 0; u < 4; u++) {
|
|
10
|
+
for (let v = 0; v < 4; v++) {
|
|
11
|
+
cps.push(mixBilinear([], a, b, d, c, u / 3, v / 3));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return new BPatch(cps, attribs);
|
|
15
|
+
};
|
|
16
|
+
export const bpatchFromHex = (pts, attribs) => {
|
|
17
|
+
assert(pts.length === 6, "require 6 points");
|
|
18
|
+
const [a, b, c, d, e, f] = pts;
|
|
19
|
+
return new BPatch([e, e, f, f, d, d, a, a, d, d, a, a, c, c, b, b], attribs);
|
|
20
|
+
};
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./api/aabb.js";
|
|
2
2
|
export * from "./api/apc.js";
|
|
3
3
|
export * from "./api/arc.js";
|
|
4
|
+
export * from "./api/bpatch.js";
|
|
4
5
|
export * from "./api/circle.js";
|
|
5
6
|
export * from "./api/cubic.js";
|
|
6
7
|
export * from "./api/ellipse.js";
|
|
@@ -21,6 +22,7 @@ export * from "./api/text.js";
|
|
|
21
22
|
export * from "./api/triangle.js";
|
|
22
23
|
export * from "./aabb.js";
|
|
23
24
|
export * from "./arc.js";
|
|
25
|
+
export * from "./bpatch.js";
|
|
24
26
|
export * from "./circle.js";
|
|
25
27
|
export * from "./cubic.js";
|
|
26
28
|
export * from "./ellipse.js";
|
package/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./api/aabb.js";
|
|
2
2
|
export * from "./api/apc.js";
|
|
3
3
|
export * from "./api/arc.js";
|
|
4
|
+
export * from "./api/bpatch.js";
|
|
4
5
|
export * from "./api/circle.js";
|
|
5
6
|
export * from "./api/cubic.js";
|
|
6
7
|
export * from "./api/ellipse.js";
|
|
@@ -21,6 +22,7 @@ export * from "./api/text.js";
|
|
|
21
22
|
export * from "./api/triangle.js";
|
|
22
23
|
export * from "./aabb.js";
|
|
23
24
|
export * from "./arc.js";
|
|
25
|
+
export * from "./bpatch.js";
|
|
24
26
|
export * from "./circle.js";
|
|
25
27
|
export * from "./cubic.js";
|
|
26
28
|
export * from "./ellipse.js";
|
package/internal/args.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Takes an array of arguments, checks if last element is a plain object
|
|
3
|
-
* and if so, removes
|
|
4
|
-
* `undefined`.
|
|
2
|
+
* Takes an array of arguments, checks if last element is a plain object or
|
|
3
|
+
* nullish and if so, removes value from array and returns it (`null` will be
|
|
4
|
+
* cast to `undefined`). Else returns `undefined`.
|
|
5
5
|
*
|
|
6
6
|
* @param args -
|
|
7
7
|
*
|
package/internal/args.js
CHANGED
|
@@ -1,16 +1,24 @@
|
|
|
1
|
-
import { peek } from "@thi.ng/arrays/peek";
|
|
2
1
|
import { isNumber } from "@thi.ng/checks/is-number";
|
|
3
2
|
import { isPlainObject } from "@thi.ng/checks/is-plain-object";
|
|
4
3
|
/**
|
|
5
|
-
* Takes an array of arguments, checks if last element is a plain object
|
|
6
|
-
* and if so, removes
|
|
7
|
-
* `undefined`.
|
|
4
|
+
* Takes an array of arguments, checks if last element is a plain object or
|
|
5
|
+
* nullish and if so, removes value from array and returns it (`null` will be
|
|
6
|
+
* cast to `undefined`). Else returns `undefined`.
|
|
8
7
|
*
|
|
9
8
|
* @param args -
|
|
10
9
|
*
|
|
11
10
|
* @internal
|
|
12
11
|
*/
|
|
13
|
-
export const __argAttribs = (args) =>
|
|
12
|
+
export const __argAttribs = (args) => {
|
|
13
|
+
if (args.length) {
|
|
14
|
+
const last = args[args.length - 1];
|
|
15
|
+
return isPlainObject(last)
|
|
16
|
+
? args.pop()
|
|
17
|
+
: last == null
|
|
18
|
+
? (args.pop(), undefined)
|
|
19
|
+
: undefined;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
14
22
|
/**
|
|
15
23
|
* Args parser for functions expecting up to 2 vector args and optional
|
|
16
24
|
* attribs object. Returns 3-tuple of re-structured args.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/geom",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.2",
|
|
4
4
|
"description": "Functional, polymorphic API for 2D geometry types & SVG generation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -31,43 +31,45 @@
|
|
|
31
31
|
"doc:readme": "yarn doc:stats && tools:readme",
|
|
32
32
|
"doc:stats": "tools:module-stats",
|
|
33
33
|
"pub": "yarn npm publish --access public",
|
|
34
|
-
"test": "testament test"
|
|
34
|
+
"test": "testament test",
|
|
35
|
+
"tool:bpatch": "tools:node-esm tools/bpatch.ts"
|
|
35
36
|
},
|
|
36
37
|
"dependencies": {
|
|
37
|
-
"@thi.ng/api": "^8.3.
|
|
38
|
-
"@thi.ng/arrays": "^2.1
|
|
39
|
-
"@thi.ng/
|
|
40
|
-
"@thi.ng/
|
|
41
|
-
"@thi.ng/
|
|
42
|
-
"@thi.ng/
|
|
43
|
-
"@thi.ng/
|
|
44
|
-
"@thi.ng/geom-
|
|
45
|
-
"@thi.ng/geom-
|
|
46
|
-
"@thi.ng/geom-clip-
|
|
47
|
-
"@thi.ng/geom-
|
|
48
|
-
"@thi.ng/geom-
|
|
49
|
-
"@thi.ng/geom-
|
|
50
|
-
"@thi.ng/geom-
|
|
51
|
-
"@thi.ng/geom-
|
|
52
|
-
"@thi.ng/geom-
|
|
53
|
-
"@thi.ng/geom-
|
|
54
|
-
"@thi.ng/geom-
|
|
55
|
-
"@thi.ng/
|
|
56
|
-
"@thi.ng/hiccup
|
|
57
|
-
"@thi.ng/
|
|
58
|
-
"@thi.ng/
|
|
59
|
-
"@thi.ng/
|
|
60
|
-
"@thi.ng/
|
|
61
|
-
"@thi.ng/
|
|
62
|
-
"@thi.ng/
|
|
38
|
+
"@thi.ng/api": "^8.3.5",
|
|
39
|
+
"@thi.ng/arrays": "^2.2.1",
|
|
40
|
+
"@thi.ng/associative": "^6.1.6",
|
|
41
|
+
"@thi.ng/checks": "^3.1.5",
|
|
42
|
+
"@thi.ng/defmulti": "^2.1.5",
|
|
43
|
+
"@thi.ng/equiv": "^2.1.5",
|
|
44
|
+
"@thi.ng/errors": "^2.1.5",
|
|
45
|
+
"@thi.ng/geom-api": "^3.1.10",
|
|
46
|
+
"@thi.ng/geom-arc": "^2.1.10",
|
|
47
|
+
"@thi.ng/geom-clip-line": "^2.1.10",
|
|
48
|
+
"@thi.ng/geom-clip-poly": "^2.1.10",
|
|
49
|
+
"@thi.ng/geom-closest-point": "^2.1.10",
|
|
50
|
+
"@thi.ng/geom-hull": "^2.1.10",
|
|
51
|
+
"@thi.ng/geom-isec": "^2.1.10",
|
|
52
|
+
"@thi.ng/geom-poly-utils": "^2.2.2",
|
|
53
|
+
"@thi.ng/geom-resample": "^2.1.10",
|
|
54
|
+
"@thi.ng/geom-splines": "^2.1.10",
|
|
55
|
+
"@thi.ng/geom-subdiv-curve": "^2.1.10",
|
|
56
|
+
"@thi.ng/geom-tessellate": "^2.1.10",
|
|
57
|
+
"@thi.ng/hiccup": "^4.2.6",
|
|
58
|
+
"@thi.ng/hiccup-svg": "^4.2.10",
|
|
59
|
+
"@thi.ng/math": "^5.3.1",
|
|
60
|
+
"@thi.ng/matrices": "^2.1.10",
|
|
61
|
+
"@thi.ng/random": "^3.2.5",
|
|
62
|
+
"@thi.ng/strings": "^3.3.3",
|
|
63
|
+
"@thi.ng/transducers": "^8.3.1",
|
|
64
|
+
"@thi.ng/vectors": "^7.5.2"
|
|
63
65
|
},
|
|
64
66
|
"devDependencies": {
|
|
65
|
-
"@microsoft/api-extractor": "^7.19.
|
|
66
|
-
"@thi.ng/testament": "^0.2.
|
|
67
|
+
"@microsoft/api-extractor": "^7.19.4",
|
|
68
|
+
"@thi.ng/testament": "^0.2.5",
|
|
67
69
|
"rimraf": "^3.0.2",
|
|
68
70
|
"tools": "^0.0.1",
|
|
69
|
-
"typedoc": "^0.22.
|
|
70
|
-
"typescript": "^4.
|
|
71
|
+
"typedoc": "^0.22.13",
|
|
72
|
+
"typescript": "^4.6.2"
|
|
71
73
|
},
|
|
72
74
|
"keywords": [
|
|
73
75
|
"2d",
|
|
@@ -105,254 +107,260 @@
|
|
|
105
107
|
],
|
|
106
108
|
"exports": {
|
|
107
109
|
".": {
|
|
108
|
-
"
|
|
110
|
+
"default": "./index.js"
|
|
109
111
|
},
|
|
110
112
|
"./aabb": {
|
|
111
|
-
"
|
|
113
|
+
"default": "./aabb.js"
|
|
112
114
|
},
|
|
113
115
|
"./api/aabb": {
|
|
114
|
-
"
|
|
116
|
+
"default": "./api/aabb.js"
|
|
115
117
|
},
|
|
116
118
|
"./api/apc": {
|
|
117
|
-
"
|
|
119
|
+
"default": "./api/apc.js"
|
|
118
120
|
},
|
|
119
121
|
"./api/arc": {
|
|
120
|
-
"
|
|
122
|
+
"default": "./api/arc.js"
|
|
123
|
+
},
|
|
124
|
+
"./api/bpatch": {
|
|
125
|
+
"default": "./api/bpatch.js"
|
|
121
126
|
},
|
|
122
127
|
"./api/circle": {
|
|
123
|
-
"
|
|
128
|
+
"default": "./api/circle.js"
|
|
124
129
|
},
|
|
125
130
|
"./api/cubic": {
|
|
126
|
-
"
|
|
131
|
+
"default": "./api/cubic.js"
|
|
127
132
|
},
|
|
128
133
|
"./api/ellipse": {
|
|
129
|
-
"
|
|
134
|
+
"default": "./api/ellipse.js"
|
|
130
135
|
},
|
|
131
136
|
"./api/group": {
|
|
132
|
-
"
|
|
137
|
+
"default": "./api/group.js"
|
|
133
138
|
},
|
|
134
139
|
"./api/line": {
|
|
135
|
-
"
|
|
140
|
+
"default": "./api/line.js"
|
|
136
141
|
},
|
|
137
142
|
"./api/path": {
|
|
138
|
-
"
|
|
143
|
+
"default": "./api/path.js"
|
|
139
144
|
},
|
|
140
145
|
"./api/plane": {
|
|
141
|
-
"
|
|
146
|
+
"default": "./api/plane.js"
|
|
142
147
|
},
|
|
143
148
|
"./api/points": {
|
|
144
|
-
"
|
|
149
|
+
"default": "./api/points.js"
|
|
145
150
|
},
|
|
146
151
|
"./api/polygon": {
|
|
147
|
-
"
|
|
152
|
+
"default": "./api/polygon.js"
|
|
148
153
|
},
|
|
149
154
|
"./api/polyline": {
|
|
150
|
-
"
|
|
155
|
+
"default": "./api/polyline.js"
|
|
151
156
|
},
|
|
152
157
|
"./api/quad": {
|
|
153
|
-
"
|
|
158
|
+
"default": "./api/quad.js"
|
|
154
159
|
},
|
|
155
160
|
"./api/quad3": {
|
|
156
|
-
"
|
|
161
|
+
"default": "./api/quad3.js"
|
|
157
162
|
},
|
|
158
163
|
"./api/quadratic": {
|
|
159
|
-
"
|
|
164
|
+
"default": "./api/quadratic.js"
|
|
160
165
|
},
|
|
161
166
|
"./api/ray": {
|
|
162
|
-
"
|
|
167
|
+
"default": "./api/ray.js"
|
|
163
168
|
},
|
|
164
169
|
"./api/rect": {
|
|
165
|
-
"
|
|
170
|
+
"default": "./api/rect.js"
|
|
166
171
|
},
|
|
167
172
|
"./api/sphere": {
|
|
168
|
-
"
|
|
173
|
+
"default": "./api/sphere.js"
|
|
169
174
|
},
|
|
170
175
|
"./api/text": {
|
|
171
|
-
"
|
|
176
|
+
"default": "./api/text.js"
|
|
172
177
|
},
|
|
173
178
|
"./api/triangle": {
|
|
174
|
-
"
|
|
179
|
+
"default": "./api/triangle.js"
|
|
175
180
|
},
|
|
176
181
|
"./arc-length": {
|
|
177
|
-
"
|
|
182
|
+
"default": "./arc-length.js"
|
|
178
183
|
},
|
|
179
184
|
"./arc": {
|
|
180
|
-
"
|
|
185
|
+
"default": "./arc.js"
|
|
181
186
|
},
|
|
182
187
|
"./area": {
|
|
183
|
-
"
|
|
188
|
+
"default": "./area.js"
|
|
184
189
|
},
|
|
185
190
|
"./as-cubic": {
|
|
186
|
-
"
|
|
191
|
+
"default": "./as-cubic.js"
|
|
187
192
|
},
|
|
188
193
|
"./as-path": {
|
|
189
|
-
"
|
|
194
|
+
"default": "./as-path.js"
|
|
190
195
|
},
|
|
191
196
|
"./as-polygon": {
|
|
192
|
-
"
|
|
197
|
+
"default": "./as-polygon.js"
|
|
193
198
|
},
|
|
194
199
|
"./as-polyline": {
|
|
195
|
-
"
|
|
200
|
+
"default": "./as-polyline.js"
|
|
196
201
|
},
|
|
197
202
|
"./as-svg": {
|
|
198
|
-
"
|
|
203
|
+
"default": "./as-svg.js"
|
|
199
204
|
},
|
|
200
205
|
"./bounds": {
|
|
201
|
-
"
|
|
206
|
+
"default": "./bounds.js"
|
|
207
|
+
},
|
|
208
|
+
"./bpatch": {
|
|
209
|
+
"default": "./bpatch.js"
|
|
202
210
|
},
|
|
203
211
|
"./center": {
|
|
204
|
-
"
|
|
212
|
+
"default": "./center.js"
|
|
205
213
|
},
|
|
206
214
|
"./centroid": {
|
|
207
|
-
"
|
|
215
|
+
"default": "./centroid.js"
|
|
208
216
|
},
|
|
209
217
|
"./circle": {
|
|
210
|
-
"
|
|
218
|
+
"default": "./circle.js"
|
|
211
219
|
},
|
|
212
220
|
"./classify-point": {
|
|
213
|
-
"
|
|
221
|
+
"default": "./classify-point.js"
|
|
214
222
|
},
|
|
215
223
|
"./clip-convex": {
|
|
216
|
-
"
|
|
224
|
+
"default": "./clip-convex.js"
|
|
217
225
|
},
|
|
218
226
|
"./closest-point": {
|
|
219
|
-
"
|
|
227
|
+
"default": "./closest-point.js"
|
|
220
228
|
},
|
|
221
229
|
"./convex-hull": {
|
|
222
|
-
"
|
|
230
|
+
"default": "./convex-hull.js"
|
|
223
231
|
},
|
|
224
232
|
"./cubic": {
|
|
225
|
-
"
|
|
233
|
+
"default": "./cubic.js"
|
|
226
234
|
},
|
|
227
235
|
"./edges": {
|
|
228
|
-
"
|
|
236
|
+
"default": "./edges.js"
|
|
229
237
|
},
|
|
230
238
|
"./ellipse": {
|
|
231
|
-
"
|
|
239
|
+
"default": "./ellipse.js"
|
|
232
240
|
},
|
|
233
241
|
"./fit-into-bounds": {
|
|
234
|
-
"
|
|
242
|
+
"default": "./fit-into-bounds.js"
|
|
235
243
|
},
|
|
236
244
|
"./flip": {
|
|
237
|
-
"
|
|
245
|
+
"default": "./flip.js"
|
|
238
246
|
},
|
|
239
247
|
"./group": {
|
|
240
|
-
"
|
|
248
|
+
"default": "./group.js"
|
|
241
249
|
},
|
|
242
250
|
"./intersects": {
|
|
243
|
-
"
|
|
251
|
+
"default": "./intersects.js"
|
|
244
252
|
},
|
|
245
253
|
"./line": {
|
|
246
|
-
"
|
|
254
|
+
"default": "./line.js"
|
|
247
255
|
},
|
|
248
256
|
"./map-point": {
|
|
249
|
-
"
|
|
257
|
+
"default": "./map-point.js"
|
|
250
258
|
},
|
|
251
259
|
"./offset": {
|
|
252
|
-
"
|
|
260
|
+
"default": "./offset.js"
|
|
253
261
|
},
|
|
254
262
|
"./path-builder": {
|
|
255
|
-
"
|
|
263
|
+
"default": "./path-builder.js"
|
|
256
264
|
},
|
|
257
265
|
"./path-from-svg": {
|
|
258
|
-
"
|
|
266
|
+
"default": "./path-from-svg.js"
|
|
259
267
|
},
|
|
260
268
|
"./path": {
|
|
261
|
-
"
|
|
269
|
+
"default": "./path.js"
|
|
262
270
|
},
|
|
263
271
|
"./plane": {
|
|
264
|
-
"
|
|
272
|
+
"default": "./plane.js"
|
|
265
273
|
},
|
|
266
274
|
"./point-at": {
|
|
267
|
-
"
|
|
275
|
+
"default": "./point-at.js"
|
|
268
276
|
},
|
|
269
277
|
"./point-inside": {
|
|
270
|
-
"
|
|
278
|
+
"default": "./point-inside.js"
|
|
271
279
|
},
|
|
272
280
|
"./points": {
|
|
273
|
-
"
|
|
281
|
+
"default": "./points.js"
|
|
274
282
|
},
|
|
275
283
|
"./polygon": {
|
|
276
|
-
"
|
|
284
|
+
"default": "./polygon.js"
|
|
277
285
|
},
|
|
278
286
|
"./polyline": {
|
|
279
|
-
"
|
|
287
|
+
"default": "./polyline.js"
|
|
280
288
|
},
|
|
281
289
|
"./quad": {
|
|
282
|
-
"
|
|
290
|
+
"default": "./quad.js"
|
|
283
291
|
},
|
|
284
292
|
"./quadratic": {
|
|
285
|
-
"
|
|
293
|
+
"default": "./quadratic.js"
|
|
286
294
|
},
|
|
287
295
|
"./ray": {
|
|
288
|
-
"
|
|
296
|
+
"default": "./ray.js"
|
|
289
297
|
},
|
|
290
298
|
"./rect": {
|
|
291
|
-
"
|
|
299
|
+
"default": "./rect.js"
|
|
292
300
|
},
|
|
293
301
|
"./resample": {
|
|
294
|
-
"
|
|
302
|
+
"default": "./resample.js"
|
|
295
303
|
},
|
|
296
304
|
"./scatter": {
|
|
297
|
-
"
|
|
305
|
+
"default": "./scatter.js"
|
|
298
306
|
},
|
|
299
307
|
"./simplify": {
|
|
300
|
-
"
|
|
308
|
+
"default": "./simplify.js"
|
|
301
309
|
},
|
|
302
310
|
"./sphere": {
|
|
303
|
-
"
|
|
311
|
+
"default": "./sphere.js"
|
|
304
312
|
},
|
|
305
313
|
"./split-at": {
|
|
306
|
-
"
|
|
314
|
+
"default": "./split-at.js"
|
|
307
315
|
},
|
|
308
316
|
"./split-near": {
|
|
309
|
-
"
|
|
317
|
+
"default": "./split-near.js"
|
|
310
318
|
},
|
|
311
319
|
"./subdiv-curve": {
|
|
312
|
-
"
|
|
320
|
+
"default": "./subdiv-curve.js"
|
|
313
321
|
},
|
|
314
322
|
"./tangent-at": {
|
|
315
|
-
"
|
|
323
|
+
"default": "./tangent-at.js"
|
|
316
324
|
},
|
|
317
325
|
"./tessellate": {
|
|
318
|
-
"
|
|
326
|
+
"default": "./tessellate.js"
|
|
319
327
|
},
|
|
320
328
|
"./text": {
|
|
321
|
-
"
|
|
329
|
+
"default": "./text.js"
|
|
322
330
|
},
|
|
323
331
|
"./transform-vertices": {
|
|
324
|
-
"
|
|
332
|
+
"default": "./transform-vertices.js"
|
|
325
333
|
},
|
|
326
334
|
"./transform": {
|
|
327
|
-
"
|
|
335
|
+
"default": "./transform.js"
|
|
328
336
|
},
|
|
329
337
|
"./translate": {
|
|
330
|
-
"
|
|
338
|
+
"default": "./translate.js"
|
|
331
339
|
},
|
|
332
340
|
"./triangle": {
|
|
333
|
-
"
|
|
341
|
+
"default": "./triangle.js"
|
|
334
342
|
},
|
|
335
343
|
"./union": {
|
|
336
|
-
"
|
|
344
|
+
"default": "./union.js"
|
|
337
345
|
},
|
|
338
346
|
"./unmap-point": {
|
|
339
|
-
"
|
|
347
|
+
"default": "./unmap-point.js"
|
|
340
348
|
},
|
|
341
349
|
"./vertices": {
|
|
342
|
-
"
|
|
350
|
+
"default": "./vertices.js"
|
|
343
351
|
},
|
|
344
352
|
"./volume": {
|
|
345
|
-
"
|
|
353
|
+
"default": "./volume.js"
|
|
346
354
|
},
|
|
347
355
|
"./warp-points": {
|
|
348
|
-
"
|
|
356
|
+
"default": "./warp-points.js"
|
|
349
357
|
},
|
|
350
358
|
"./with-attribs": {
|
|
351
|
-
"
|
|
359
|
+
"default": "./with-attribs.js"
|
|
352
360
|
}
|
|
353
361
|
},
|
|
354
362
|
"thi.ng": {
|
|
355
363
|
"year": 2013
|
|
356
364
|
},
|
|
357
|
-
"gitHead": "
|
|
365
|
+
"gitHead": "542bf14bd0c7a56b4e6297718189eea772a824b7\n"
|
|
358
366
|
}
|
package/polygon.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Attribs } from "@thi.ng/geom-api";
|
|
2
2
|
import type { Vec } from "@thi.ng/vectors";
|
|
3
3
|
import { Polygon } from "./api/polygon.js";
|
|
4
|
-
export declare const polygon: (pts
|
|
4
|
+
export declare const polygon: (pts?: Vec[] | undefined, attribs?: Attribs | undefined) => Polygon;
|
|
5
5
|
export declare const star: (r: number, n: number, profile: number[], attribs?: Attribs | undefined) => Polygon;
|
|
6
6
|
//# sourceMappingURL=polygon.d.ts.map
|
package/rect.d.ts
CHANGED
|
@@ -12,8 +12,8 @@ export declare const rectFromCentroid: (centroid: Vec, size: Vec, attribs?: Attr
|
|
|
12
12
|
* Returns the intersection rect of given inputs or `undefined` if they
|
|
13
13
|
* are non-overlapping.
|
|
14
14
|
*
|
|
15
|
-
* @param a
|
|
16
|
-
* @param b
|
|
15
|
+
* @param a -
|
|
16
|
+
* @param b -
|
|
17
17
|
*/
|
|
18
18
|
export declare const intersectionRect: (a: Rect, b: Rect) => Rect | undefined;
|
|
19
19
|
/**
|
package/rect.js
CHANGED
|
@@ -19,8 +19,8 @@ export const rectFromCentroid = (centroid, size, attribs) => new Rect(maddN2([],
|
|
|
19
19
|
* Returns the intersection rect of given inputs or `undefined` if they
|
|
20
20
|
* are non-overlapping.
|
|
21
21
|
*
|
|
22
|
-
* @param a
|
|
23
|
-
* @param b
|
|
22
|
+
* @param a -
|
|
23
|
+
* @param b -
|
|
24
24
|
*/
|
|
25
25
|
export const intersectionRect = (a, b) => {
|
|
26
26
|
const p = max2([], a.pos, b.pos);
|
package/vertices.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare const vertices: MultiFn1O<IShape, number | Partial<SamplingOpts>,
|
|
|
7
7
|
* Takes array of vectors or an `IShape`. If the latter, calls {@link vertices}
|
|
8
8
|
* and return result, else returns original array.
|
|
9
9
|
*
|
|
10
|
-
* @param shape
|
|
10
|
+
* @param shape -
|
|
11
11
|
*/
|
|
12
12
|
export declare const ensureVertices: (shape: IShape | Vec[]) => Vec[];
|
|
13
13
|
//# sourceMappingURL=vertices.d.ts.map
|
package/vertices.js
CHANGED
|
@@ -16,6 +16,7 @@ import { Polygon } from "./api/polygon.js";
|
|
|
16
16
|
import { __dispatch } from "./internal/dispatch.js";
|
|
17
17
|
export const vertices = defmulti(__dispatch, {
|
|
18
18
|
line: "polyline",
|
|
19
|
+
bpatch: "points",
|
|
19
20
|
points3: "points",
|
|
20
21
|
quad: "poly",
|
|
21
22
|
tri: "poly",
|
|
@@ -98,7 +99,7 @@ export const vertices = defmulti(__dispatch, {
|
|
|
98
99
|
* Takes array of vectors or an `IShape`. If the latter, calls {@link vertices}
|
|
99
100
|
* and return result, else returns original array.
|
|
100
101
|
*
|
|
101
|
-
* @param shape
|
|
102
|
+
* @param shape -
|
|
102
103
|
*/
|
|
103
104
|
export const ensureVertices = (shape) => isArray(shape) ? shape : vertices(shape);
|
|
104
105
|
const circleOpts = (opts, r) => isNumber(opts)
|
package/warp-points.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { IShape } from "@thi.ng/geom-api";
|
|
2
|
-
import type { ReadonlyVec, Vec } from "@thi.ng/vectors";
|
|
2
|
+
import type { ReadonlyVec, Vec } from "@thi.ng/vectors/api";
|
|
3
|
+
import type { BPatch } from "./api/bpatch.js";
|
|
4
|
+
import type { Rect } from "./api/rect.js";
|
|
3
5
|
export declare const warpPoints: (pts: ReadonlyVec[], dest: IShape, src: IShape) => Vec[];
|
|
6
|
+
export declare const warpPointsBPatch: (pts: ReadonlyVec[], dest: BPatch, src?: Rect | undefined, out?: Vec[]) => Vec[];
|
|
4
7
|
//# sourceMappingURL=warp-points.d.ts.map
|
package/warp-points.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { bounds2 } from "@thi.ng/geom-poly-utils/bounds";
|
|
1
2
|
import { mapPoint } from "./map-point.js";
|
|
3
|
+
import { rectFromMinMax } from "./rect.js";
|
|
2
4
|
import { unmapPoint } from "./unmap-point.js";
|
|
3
5
|
export const warpPoints = (pts, dest, src) => {
|
|
4
6
|
const res = [];
|
|
@@ -7,3 +9,10 @@ export const warpPoints = (pts, dest, src) => {
|
|
|
7
9
|
}
|
|
8
10
|
return res;
|
|
9
11
|
};
|
|
12
|
+
export const warpPointsBPatch = (pts, dest, src, out = []) => {
|
|
13
|
+
src = src || rectFromMinMax(...bounds2(pts));
|
|
14
|
+
for (let i = pts.length; i-- > 0;) {
|
|
15
|
+
out[i] = dest.unmapPoint(mapPoint(src, pts[i]));
|
|
16
|
+
}
|
|
17
|
+
return out;
|
|
18
|
+
};
|