@thi.ng/geom 3.3.0 → 3.3.1
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 -1
- package/api/aabb.js +4 -4
- package/api/ellipse.js +2 -2
- package/api/plane.js +2 -2
- package/api/rect.js +2 -2
- package/internal/args.d.ts +2 -0
- package/internal/args.js +2 -0
- package/package.json +13 -13
- package/rect.d.ts +2 -2
- package/rect.js +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2022-06-
|
|
3
|
+
- **Last updated**: 2022-06-23T12:16:18Z
|
|
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
|
+
### [3.3.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/geom@3.3.1) (2022-06-23)
|
|
13
|
+
|
|
14
|
+
#### ♻️ Refactoring
|
|
15
|
+
|
|
16
|
+
- update size handling in various ctors ([ab4b93d](https://github.com/thi-ng/umbrella/commit/ab4b93d))
|
|
17
|
+
|
|
12
18
|
## [3.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/geom@3.3.0) (2022-06-20)
|
|
13
19
|
|
|
14
20
|
#### 🚀 Features
|
package/README.md
CHANGED
|
@@ -50,6 +50,7 @@ themselves too):
|
|
|
50
50
|
- [@thi.ng/geom-isoline](https://github.com/thi-ng/umbrella/tree/develop/packages/geom-isoline) - Fast 2D contour line extraction / generation
|
|
51
51
|
- [@thi.ng/geom-poly-utils](https://github.com/thi-ng/umbrella/tree/develop/packages/geom-poly-utils) - 2D polygon/polyline analysis & processing utilities
|
|
52
52
|
- [@thi.ng/geom-resample](https://github.com/thi-ng/umbrella/tree/develop/packages/geom-resample) - Customizable nD polyline interpolation, re-sampling, splitting & nearest point computation
|
|
53
|
+
- [@thi.ng/geom-sdf](https://github.com/thi-ng/umbrella/tree/develop/packages/geom-sdf) - 2D Signed Distance Field creation from [@thi.ng/geom](https://github.com/thi-ng/umbrella/tree/develop/packages/geom) shapes, conversions, sampling, combinators
|
|
53
54
|
- [@thi.ng/geom-splines](https://github.com/thi-ng/umbrella/tree/develop/packages/geom-splines) - nD cubic & quadratic curve analysis, conversion, interpolation, splitting
|
|
54
55
|
- [@thi.ng/geom-subdiv-curve](https://github.com/thi-ng/umbrella/tree/develop/packages/geom-subdiv-curve) - Freely customizable, iterative nD subdivision curves for open / closed geometries
|
|
55
56
|
- [@thi.ng/geom-tessellate](https://github.com/thi-ng/umbrella/tree/develop/packages/geom-tessellate) - 2D/3D convex polygon tessellators
|
|
@@ -84,7 +85,7 @@ node --experimental-repl-await
|
|
|
84
85
|
> const geom = await import("@thi.ng/geom");
|
|
85
86
|
```
|
|
86
87
|
|
|
87
|
-
Package sizes (gzipped, pre-treeshake): ESM: 12.
|
|
88
|
+
Package sizes (gzipped, pre-treeshake): ESM: 12.67 KB
|
|
88
89
|
|
|
89
90
|
## Dependencies
|
|
90
91
|
|
package/api/aabb.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { isNumber } from "@thi.ng/checks/is-number";
|
|
2
1
|
import { add3 } from "@thi.ng/vectors/add";
|
|
3
2
|
import { addN3 } from "@thi.ng/vectors/addn";
|
|
4
|
-
import {
|
|
3
|
+
import { set3 } from "@thi.ng/vectors/set";
|
|
5
4
|
import { subN3 } from "@thi.ng/vectors/subn";
|
|
5
|
+
import { __asVec } from "../internal/args.js";
|
|
6
6
|
import { __copyAttribs } from "../internal/copy.js";
|
|
7
7
|
export class AABB {
|
|
8
8
|
constructor(pos = [0, 0, 0], size = 1, attribs) {
|
|
9
9
|
this.pos = pos;
|
|
10
10
|
this.attribs = attribs;
|
|
11
|
-
this.size =
|
|
11
|
+
this.size = __asVec(size, 3);
|
|
12
12
|
}
|
|
13
13
|
get type() {
|
|
14
14
|
return "aabb";
|
|
15
15
|
}
|
|
16
16
|
copy() {
|
|
17
|
-
return new AABB(
|
|
17
|
+
return new AABB(set3([], this.pos), set3([], this.size), __copyAttribs(this));
|
|
18
18
|
}
|
|
19
19
|
max() {
|
|
20
20
|
return add3([], this.pos, this.size);
|
package/api/ellipse.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { isNumber } from "@thi.ng/checks/is-number";
|
|
2
1
|
import { set } from "@thi.ng/vectors/set";
|
|
2
|
+
import { __asVec } from "../internal/args.js";
|
|
3
3
|
import { __copyAttribs } from "../internal/copy.js";
|
|
4
4
|
export class Ellipse {
|
|
5
5
|
constructor(pos = [0, 0], r = [1, 1], attribs) {
|
|
6
6
|
this.pos = pos;
|
|
7
7
|
this.attribs = attribs;
|
|
8
|
-
this.r =
|
|
8
|
+
this.r = __asVec(r);
|
|
9
9
|
}
|
|
10
10
|
get type() {
|
|
11
11
|
return "ellipse";
|
package/api/plane.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { set3 } from "@thi.ng/vectors/set";
|
|
2
2
|
import { __copyAttribs } from "../internal/copy.js";
|
|
3
3
|
export class Plane {
|
|
4
4
|
constructor(normal = [0, 1, 0], w = 0, attribs) {
|
|
@@ -10,7 +10,7 @@ export class Plane {
|
|
|
10
10
|
return "plane";
|
|
11
11
|
}
|
|
12
12
|
copy() {
|
|
13
|
-
return new Plane(
|
|
13
|
+
return new Plane(set3([], this.normal), this.w, __copyAttribs(this));
|
|
14
14
|
}
|
|
15
15
|
toHiccup() {
|
|
16
16
|
return ["plane", this.attribs, this.normal, this.w];
|
package/api/rect.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { isNumber } from "@thi.ng/checks/is-number";
|
|
2
1
|
import { add2 } from "@thi.ng/vectors/add";
|
|
3
2
|
import { addN2 } from "@thi.ng/vectors/addn";
|
|
4
3
|
import { set2 } from "@thi.ng/vectors/set";
|
|
5
4
|
import { subN2 } from "@thi.ng/vectors/subn";
|
|
5
|
+
import { __asVec } from "../internal/args.js";
|
|
6
6
|
import { __copyAttribs } from "../internal/copy.js";
|
|
7
7
|
export class Rect {
|
|
8
8
|
constructor(pos = [0, 0], size = 1, attribs) {
|
|
9
9
|
this.pos = pos;
|
|
10
10
|
this.attribs = attribs;
|
|
11
|
-
this.size =
|
|
11
|
+
this.size = __asVec(size);
|
|
12
12
|
}
|
|
13
13
|
get type() {
|
|
14
14
|
return "rect";
|
package/internal/args.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Vec } from "@thi.ng/vectors";
|
|
1
2
|
/**
|
|
2
3
|
* Takes an array of arguments, checks if last element is a plain object or
|
|
3
4
|
* nullish and if so, removes value from array and returns it (`null` will be
|
|
@@ -26,4 +27,5 @@ export declare const __argsVV: (args: any[]) => any[];
|
|
|
26
27
|
* @internal
|
|
27
28
|
*/
|
|
28
29
|
export declare const __argsVN: (args: any[]) => any[];
|
|
30
|
+
export declare const __asVec: (x: number | Vec, size?: number) => any[] | Vec;
|
|
29
31
|
//# sourceMappingURL=args.d.ts.map
|
package/internal/args.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isNumber } from "@thi.ng/checks/is-number";
|
|
2
2
|
import { isPlainObject } from "@thi.ng/checks/is-plain-object";
|
|
3
|
+
import { vecOf } from "@thi.ng/vectors/vec-of";
|
|
3
4
|
/**
|
|
4
5
|
* Takes an array of arguments, checks if last element is a plain object or
|
|
5
6
|
* nullish and if so, removes value from array and returns it (`null` will be
|
|
@@ -53,3 +54,4 @@ export const __argsVN = (args) => {
|
|
|
53
54
|
: [args[0], undefined, attr]
|
|
54
55
|
: [undefined, undefined, attr];
|
|
55
56
|
};
|
|
57
|
+
export const __asVec = (x, size = 2) => isNumber(x) ? vecOf(size, x) : x;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/geom",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.1",
|
|
4
4
|
"description": "Functional, polymorphic API for 2D geometry types & SVG generation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -42,20 +42,20 @@
|
|
|
42
42
|
"@thi.ng/defmulti": "^2.1.7",
|
|
43
43
|
"@thi.ng/equiv": "^2.1.7",
|
|
44
44
|
"@thi.ng/errors": "^2.1.7",
|
|
45
|
-
"@thi.ng/geom-api": "^3.2.
|
|
46
|
-
"@thi.ng/geom-arc": "^2.1.
|
|
47
|
-
"@thi.ng/geom-clip-line": "^2.1.
|
|
48
|
-
"@thi.ng/geom-clip-poly": "^2.1.
|
|
45
|
+
"@thi.ng/geom-api": "^3.2.1",
|
|
46
|
+
"@thi.ng/geom-arc": "^2.1.16",
|
|
47
|
+
"@thi.ng/geom-clip-line": "^2.1.16",
|
|
48
|
+
"@thi.ng/geom-clip-poly": "^2.1.16",
|
|
49
49
|
"@thi.ng/geom-closest-point": "^2.1.14",
|
|
50
50
|
"@thi.ng/geom-hull": "^2.1.14",
|
|
51
|
-
"@thi.ng/geom-isec": "^2.1.
|
|
52
|
-
"@thi.ng/geom-poly-utils": "^2.
|
|
53
|
-
"@thi.ng/geom-resample": "^2.1.
|
|
54
|
-
"@thi.ng/geom-splines": "^2.1.
|
|
55
|
-
"@thi.ng/geom-subdiv-curve": "^2.1.
|
|
56
|
-
"@thi.ng/geom-tessellate": "^2.1.
|
|
51
|
+
"@thi.ng/geom-isec": "^2.1.16",
|
|
52
|
+
"@thi.ng/geom-poly-utils": "^2.3.0",
|
|
53
|
+
"@thi.ng/geom-resample": "^2.1.16",
|
|
54
|
+
"@thi.ng/geom-splines": "^2.1.16",
|
|
55
|
+
"@thi.ng/geom-subdiv-curve": "^2.1.16",
|
|
56
|
+
"@thi.ng/geom-tessellate": "^2.1.16",
|
|
57
57
|
"@thi.ng/hiccup": "^4.2.9",
|
|
58
|
-
"@thi.ng/hiccup-svg": "^4.3.
|
|
58
|
+
"@thi.ng/hiccup-svg": "^4.3.1",
|
|
59
59
|
"@thi.ng/math": "^5.3.3",
|
|
60
60
|
"@thi.ng/matrices": "^2.1.14",
|
|
61
61
|
"@thi.ng/random": "^3.3.2",
|
|
@@ -371,5 +371,5 @@
|
|
|
371
371
|
"thi.ng": {
|
|
372
372
|
"year": 2013
|
|
373
373
|
},
|
|
374
|
-
"gitHead": "
|
|
374
|
+
"gitHead": "73139849c7b46c0451693d994e14a34bc2434280\n"
|
|
375
375
|
}
|
package/rect.d.ts
CHANGED
|
@@ -8,8 +8,8 @@ export declare function rect(size: number | Vec, attribs?: Attribs): Rect;
|
|
|
8
8
|
export declare function rect(attribs?: Attribs): Rect;
|
|
9
9
|
export declare const rectFromMinMax: (min: Vec, max: Vec, attribs?: Attribs) => Rect;
|
|
10
10
|
export declare const rectFromMinMaxWithMargin: (min: Vec, max: Vec, margin: number, attribs?: Attribs) => Rect;
|
|
11
|
-
export declare const rectFromCentroid: (centroid: Vec, size: Vec, attribs?: Attribs) => Rect;
|
|
12
|
-
export declare const rectFromCentroidWithMargin: (centroid: Vec, size: Vec, margin: number, attribs?: Attribs) => Rect;
|
|
11
|
+
export declare const rectFromCentroid: (centroid: Vec, size: number | Vec, attribs?: Attribs) => Rect;
|
|
12
|
+
export declare const rectFromCentroidWithMargin: (centroid: Vec, size: number | Vec, margin: number, attribs?: Attribs) => Rect;
|
|
13
13
|
/**
|
|
14
14
|
* Returns the intersection rect of given inputs or `undefined` if they
|
|
15
15
|
* are non-overlapping.
|
package/rect.js
CHANGED
|
@@ -9,13 +9,16 @@ import { min2 } from "@thi.ng/vectors/min";
|
|
|
9
9
|
import { sub2 } from "@thi.ng/vectors/sub";
|
|
10
10
|
import { subN2 } from "@thi.ng/vectors/subn";
|
|
11
11
|
import { Rect } from "./api/rect.js";
|
|
12
|
-
import { __argsVV } from "./internal/args.js";
|
|
12
|
+
import { __argsVV, __asVec } from "./internal/args.js";
|
|
13
13
|
export function rect(...args) {
|
|
14
14
|
return new Rect(...__argsVV(args));
|
|
15
15
|
}
|
|
16
16
|
export const rectFromMinMax = (min, max, attribs) => new Rect(min, sub2([], max, min), attribs);
|
|
17
17
|
export const rectFromMinMaxWithMargin = (min, max, margin, attribs) => rectFromMinMax(min, max, attribs).offset(margin);
|
|
18
|
-
export const rectFromCentroid = (centroid, size, attribs) =>
|
|
18
|
+
export const rectFromCentroid = (centroid, size, attribs) => {
|
|
19
|
+
size = __asVec(size);
|
|
20
|
+
return new Rect(maddN2([], size, -0.5, centroid), size, attribs);
|
|
21
|
+
};
|
|
19
22
|
export const rectFromCentroidWithMargin = (centroid, size, margin, attribs) => rectFromCentroid(centroid, size, attribs).offset(margin);
|
|
20
23
|
/**
|
|
21
24
|
* Returns the intersection rect of given inputs or `undefined` if they
|