@thi.ng/geom 7.0.1 → 8.0.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 +196 -1
- package/README.md +357 -114
- package/aabb.d.ts +26 -1
- package/api/aabb.d.ts +5 -4
- package/api/aabb.js +10 -7
- package/api/apc.d.ts +5 -3
- package/api/arc.d.ts +6 -5
- package/api/arc.js +3 -4
- package/api/bpatch.d.ts +6 -3
- package/api/bpatch.js +5 -3
- package/api/circle.d.ts +4 -3
- package/api/circle.js +9 -6
- package/api/complex-polygon.d.ts +7 -3
- package/api/complex-polygon.js +14 -4
- package/api/cubic.d.ts +8 -5
- package/api/cubic.js +12 -6
- package/api/cubic3.d.ts +15 -0
- package/api/cubic3.js +38 -0
- package/api/ellipse.d.ts +4 -3
- package/api/ellipse.js +7 -8
- package/api/extra.d.ts +15 -0
- package/api/extra.js +19 -0
- package/api/group.d.ts +12 -11
- package/api/group.js +4 -5
- package/api/group3.d.ts +30 -0
- package/api/group3.js +48 -0
- package/api/line.d.ts +8 -5
- package/api/line.js +8 -8
- package/api/line3.d.ts +15 -0
- package/api/line3.js +29 -0
- package/api/path.d.ts +14 -11
- package/api/path.js +17 -12
- package/api/path3.d.ts +28 -0
- package/api/path3.js +91 -0
- package/api/plane.d.ts +4 -3
- package/api/plane.js +7 -4
- package/api/points.d.ts +8 -10
- package/api/points.js +7 -20
- package/api/points3.d.ts +13 -0
- package/api/points3.js +21 -0
- package/api/polygon.d.ts +7 -4
- package/api/polygon.js +5 -3
- package/api/polygon3.d.ts +14 -0
- package/api/polygon3.js +24 -0
- package/api/polyline.d.ts +18 -4
- package/api/polyline.js +8 -5
- package/api/polyline3.d.ts +28 -0
- package/api/polyline3.js +31 -0
- package/api/quad.d.ts +7 -4
- package/api/quad.js +5 -3
- package/api/quad3.d.ts +7 -4
- package/api/quad3.js +6 -4
- package/api/quadratic.d.ts +8 -5
- package/api/quadratic.js +12 -6
- package/api/quadratic3.d.ts +15 -0
- package/api/quadratic3.js +38 -0
- package/api/ray.d.ts +4 -3
- package/api/ray.js +6 -7
- package/api/ray3.d.ts +14 -0
- package/api/ray3.js +33 -0
- package/api/rect.d.ts +5 -3
- package/api/rect.js +11 -8
- package/api/sphere.d.ts +4 -3
- package/api/sphere.js +8 -5
- package/api/text.d.ts +4 -3
- package/api/text.js +8 -5
- package/api/triangle.d.ts +7 -4
- package/api/triangle.js +5 -3
- package/api/triangle3.d.ts +14 -0
- package/api/triangle3.js +26 -0
- package/api.d.ts +193 -0
- package/api.js +10 -0
- package/apply-transforms.d.ts +33 -11
- package/apply-transforms.js +24 -4
- package/arc-length.d.ts +18 -4
- package/arc-length.js +18 -3
- package/arc.d.ts +1 -1
- package/area.d.ts +6 -10
- package/area.js +3 -3
- package/as-cubic.d.ts +31 -5
- package/as-cubic.js +86 -24
- package/as-path.d.ts +14 -7
- package/as-path.js +49 -24
- package/as-polygon.d.ts +20 -5
- package/as-polygon.js +46 -12
- package/as-polyline.d.ts +18 -5
- package/as-polyline.js +29 -23
- package/as-sector.d.ts +13 -0
- package/as-sector.js +18 -0
- package/as-svg.d.ts +31 -9
- package/as-svg.js +21 -18
- package/bounds.d.ts +12 -2
- package/bounds.js +15 -0
- package/bpatch.d.ts +26 -1
- package/center-of-weight.d.ts +22 -0
- package/center-of-weight.js +23 -0
- package/center.d.ts +11 -5
- package/center.js +9 -4
- package/centroid-of-bounds.d.ts +12 -0
- package/centroid-of-bounds.js +9 -0
- package/centroid.d.ts +14 -4
- package/centroid.js +16 -17
- package/circle.d.ts +1 -1
- package/classify-point.d.ts +3 -1
- package/classify-point.js +7 -4
- package/clip-convex.d.ts +27 -8
- package/clip-convex.js +52 -17
- package/closest-point.d.ts +1 -1
- package/complex-polygon-from-path.d.ts +1 -1
- package/complex-polygon.d.ts +1 -1
- package/convex-hull.d.ts +9 -2
- package/convex-hull.js +3 -3
- package/convolve.d.ts +72 -0
- package/convolve.js +33 -0
- package/cubic.d.ts +1 -1
- package/cubic.js +7 -7
- package/cubic3.d.ts +8 -0
- package/cubic3.js +14 -0
- package/edges.d.ts +2 -2
- package/ellipse.d.ts +1 -1
- package/extra.d.ts +14 -0
- package/extra.js +5 -0
- package/fit-into-bounds.d.ts +14 -4
- package/fit-into-bounds.js +6 -6
- package/flip.d.ts +21 -5
- package/flip.js +19 -12
- package/from-tessellation.d.ts +81 -0
- package/from-tessellation.js +27 -0
- package/group.d.ts +2 -2
- package/group3.d.ts +16 -0
- package/group3.js +5 -0
- package/index.d.ts +36 -1
- package/index.js +36 -1
- package/internal/bounds.d.ts +3 -4
- package/internal/copy.d.ts +8 -7
- package/internal/copy.js +3 -7
- package/internal/dispatch.d.ts +1 -1
- package/internal/error.d.ts +3 -0
- package/internal/error.js +6 -0
- package/internal/pclike.d.ts +3 -2
- package/internal/pclike.js +6 -0
- package/internal/points-as-shape.d.ts +11 -2
- package/internal/points-as-shape.js +10 -1
- package/internal/split.d.ts +2 -2
- package/internal/split.js +13 -8
- package/internal/transform.d.ts +6 -22
- package/internal/transform.js +2 -21
- package/internal/vertices.d.ts +3 -2
- package/internal/vertices.js +3 -1
- package/intersects.d.ts +5 -4
- package/intersects.js +6 -4
- package/line.d.ts +1 -1
- package/line3.d.ts +6 -0
- package/line3.js +9 -0
- package/map-point.d.ts +1 -1
- package/normalized-path.d.ts +17 -0
- package/normalized-path.js +23 -0
- package/offset.d.ts +16 -2
- package/offset.js +2 -2
- package/package.json +149 -35
- package/path-builder.d.ts +42 -13
- package/path-builder.js +68 -42
- package/path-from-cubics.d.ts +26 -0
- package/path-from-cubics.js +39 -0
- package/path-from-svg.d.ts +1 -1
- package/path-from-svg.js +29 -29
- package/path.d.ts +2 -52
- package/path.js +1 -58
- package/path3.d.ts +16 -0
- package/path3.js +5 -0
- package/plane.d.ts +11 -1
- package/plane.js +3 -0
- package/point-at.d.ts +1 -1
- package/point-inside.d.ts +3 -1
- package/point-inside.js +4 -1
- package/points.d.ts +2 -3
- package/points.js +2 -4
- package/points3.d.ts +5 -0
- package/points3.js +5 -0
- package/polygon.d.ts +5 -5
- package/polygon3.d.ts +5 -0
- package/polygon3.js +5 -0
- package/polyline.d.ts +2 -2
- package/polyline3.d.ts +5 -0
- package/polyline3.js +5 -0
- package/proximity.d.ts +5 -3
- package/proximity.js +2 -2
- package/quad.d.ts +2 -7
- package/quad.js +1 -29
- package/quad3.d.ts +8 -0
- package/quad3.js +30 -0
- package/quadratic.d.ts +1 -1
- package/quadratic3.d.ts +7 -0
- package/quadratic3.js +11 -0
- package/ray.d.ts +1 -1
- package/ray.js +2 -2
- package/ray3.d.ts +5 -0
- package/ray3.js +6 -0
- package/rect.d.ts +1 -1
- package/resample.d.ts +45 -4
- package/resample.js +26 -16
- package/rotate-around-axis.d.ts +33 -0
- package/rotate-around-axis.js +57 -0
- package/rotate.d.ts +15 -2
- package/rotate.js +47 -45
- package/rounded-rect.d.ts +25 -0
- package/rounded-rect.js +18 -0
- package/scale-with-center.d.ts +2 -2
- package/scale.d.ts +24 -2
- package/scale.js +59 -43
- package/scatter.d.ts +1 -1
- package/simplify.d.ts +8 -2
- package/simplify.js +7 -4
- package/smooth-poly.d.ts +27 -0
- package/smooth-poly.js +11 -0
- package/sphere.d.ts +1 -1
- package/split-arclength.d.ts +6 -2
- package/split-at.d.ts +18 -2
- package/split-at.js +66 -34
- package/split-near.d.ts +13 -2
- package/split-near.js +23 -27
- package/subdiv-curve.d.ts +81 -27
- package/subdiv-curve.js +44 -28
- package/tangent-at.d.ts +1 -1
- package/tessellate.d.ts +72 -18
- package/tessellate.js +53 -8
- package/text.d.ts +1 -1
- package/transform-vertices.d.ts +30 -6
- package/transform-vertices.js +36 -38
- package/transform.d.ts +30 -2
- package/transform.js +54 -40
- package/translate.d.ts +12 -2
- package/translate.js +42 -43
- package/triangle.d.ts +1 -1
- package/triangle3.d.ts +6 -0
- package/triangle3.js +8 -0
- package/union.d.ts +11 -2
- package/union.js +6 -7
- package/unmap-point.d.ts +1 -1
- package/vertices.d.ts +3 -3
- package/vertices.js +14 -4
- package/volume.d.ts +1 -1
- package/warp-points.d.ts +35 -4
- package/warp-points.js +2 -0
- package/with-attribs.d.ts +4 -5
- package/internal/rotate.d.ts +0 -5
- package/internal/rotate.js +0 -8
- package/internal/scale.d.ts +0 -5
- package/internal/scale.js +0 -12
- package/internal/translate.d.ts +0 -5
- package/internal/translate.js +0 -8
package/aabb.d.ts
CHANGED
|
@@ -1,11 +1,36 @@
|
|
|
1
|
-
import type { Attribs } from "@thi.ng/geom-api";
|
|
2
1
|
import { type ReadonlyVec, type Vec } from "@thi.ng/vectors/api";
|
|
2
|
+
import type { Attribs } from "./api.js";
|
|
3
3
|
import { AABB } from "./api/aabb.js";
|
|
4
4
|
import type { Sphere } from "./api/sphere.js";
|
|
5
|
+
/**
|
|
6
|
+
* 3D shape factory. Creates a new axis-aligned bounding box, where `pos` is the
|
|
7
|
+
* min. position and `size` the extent in each dimension..
|
|
8
|
+
*
|
|
9
|
+
* @param pos
|
|
10
|
+
* @param size
|
|
11
|
+
* @param attribs
|
|
12
|
+
*/
|
|
5
13
|
export declare function aabb(pos: Vec, size: number | Vec, attribs?: Attribs): AABB;
|
|
6
14
|
export declare function aabb(size: number | Vec, attribs?: Attribs): AABB;
|
|
7
15
|
export declare function aabb(attribs?: Attribs): AABB;
|
|
16
|
+
/**
|
|
17
|
+
* 3D shape factory. Creates a new axis-aligned bounding box between given
|
|
18
|
+
* `min`/`max` points.
|
|
19
|
+
*
|
|
20
|
+
* @param min
|
|
21
|
+
* @param max
|
|
22
|
+
* @param attribs
|
|
23
|
+
*/
|
|
8
24
|
export declare const aabbFromMinMax: (min: Vec, max: Vec, attribs?: Attribs) => AABB;
|
|
25
|
+
/**
|
|
26
|
+
* Same as {@link aabbFromMinMax}, but enlarges box in all directions by
|
|
27
|
+
* `margin`.
|
|
28
|
+
*
|
|
29
|
+
* @param min
|
|
30
|
+
* @param max
|
|
31
|
+
* @param margin
|
|
32
|
+
* @param attribs
|
|
33
|
+
*/
|
|
9
34
|
export declare const aabbFromMinMaxWithMargin: (min: Vec, max: Vec, margin: number, attribs?: Attribs) => AABB;
|
|
10
35
|
export declare const aabbFromCentroid: (centroid: Vec, size: Vec, attribs?: Attribs) => AABB;
|
|
11
36
|
export declare const aabbWithCentroidAndMargin: (centroid: Vec, size: Vec, margin: number, attribs?: Attribs) => AABB;
|
package/api/aabb.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import type { IToHiccup } from "@thi.ng/api";
|
|
2
|
-
import type { AABBLike, Attribs } from "@thi.ng/geom-api";
|
|
3
1
|
import { type Vec } from "@thi.ng/vectors/api";
|
|
4
|
-
|
|
2
|
+
import type { AABBLike, Attribs, IHiccupShape3 } from "../api.js";
|
|
3
|
+
export declare class AABB implements AABBLike, IHiccupShape3<AABB> {
|
|
5
4
|
pos: Vec;
|
|
6
5
|
attribs?: Attribs | undefined;
|
|
6
|
+
readonly type = "aabb";
|
|
7
|
+
readonly dim = 3;
|
|
7
8
|
size: Vec;
|
|
8
9
|
constructor(pos?: Vec, size?: number | Vec, attribs?: Attribs | undefined);
|
|
9
|
-
get type(): string;
|
|
10
10
|
copy(): AABB;
|
|
11
11
|
withAttribs(attribs: Attribs): AABB;
|
|
12
|
+
min(): Vec;
|
|
12
13
|
max(): Vec;
|
|
13
14
|
offset(offset: number): this;
|
|
14
15
|
toHiccup(): (string | Vec | Attribs | undefined)[];
|
package/api/aabb.js
CHANGED
|
@@ -1,37 +1,40 @@
|
|
|
1
1
|
import { add3 } from "@thi.ng/vectors/add";
|
|
2
2
|
import { addN3 } from "@thi.ng/vectors/addn";
|
|
3
3
|
import { ZERO3 } from "@thi.ng/vectors/api";
|
|
4
|
+
import { maddN3 } from "@thi.ng/vectors/maddn";
|
|
4
5
|
import { max3 } from "@thi.ng/vectors/max";
|
|
5
6
|
import { set3 } from "@thi.ng/vectors/set";
|
|
6
|
-
import { subN3 } from "@thi.ng/vectors/subn";
|
|
7
7
|
import { __asVec } from "../internal/args.js";
|
|
8
8
|
import { __copyAttribs } from "../internal/copy.js";
|
|
9
9
|
class AABB {
|
|
10
10
|
constructor(pos = [0, 0, 0], size = 1, attribs) {
|
|
11
11
|
this.pos = pos;
|
|
12
12
|
this.attribs = attribs;
|
|
13
|
-
this.size = __asVec(size, 3);
|
|
13
|
+
this.size = max3(null, __asVec(size, 3), ZERO3);
|
|
14
14
|
}
|
|
15
|
+
type = "aabb";
|
|
16
|
+
dim = 3;
|
|
15
17
|
size;
|
|
16
|
-
get type() {
|
|
17
|
-
return "aabb";
|
|
18
|
-
}
|
|
19
18
|
copy() {
|
|
20
19
|
return new AABB(
|
|
21
20
|
set3([], this.pos),
|
|
22
21
|
set3([], this.size),
|
|
23
|
-
__copyAttribs(this)
|
|
22
|
+
__copyAttribs(this.attribs)
|
|
24
23
|
);
|
|
25
24
|
}
|
|
26
25
|
withAttribs(attribs) {
|
|
27
26
|
return new AABB(this.pos, this.size, attribs);
|
|
28
27
|
}
|
|
28
|
+
min() {
|
|
29
|
+
return set3([], this.pos);
|
|
30
|
+
}
|
|
29
31
|
max() {
|
|
30
32
|
return add3([], this.pos, this.size);
|
|
31
33
|
}
|
|
32
34
|
offset(offset) {
|
|
33
|
-
|
|
35
|
+
const c = maddN3([], this.size, 0.5, this.pos);
|
|
34
36
|
max3(null, addN3(null, this.size, offset * 2), ZERO3);
|
|
37
|
+
maddN3(this.pos, this.size, -0.5, c);
|
|
35
38
|
return this;
|
|
36
39
|
}
|
|
37
40
|
toHiccup() {
|
package/api/apc.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import type { IClear } from "@thi.ng/api";
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
1
|
+
import type { Fn, IClear } from "@thi.ng/api";
|
|
2
|
+
import type { ReadonlyVec, Vec } from "@thi.ng/vectors";
|
|
3
|
+
import type { Attribs, PCLike } from "../api.js";
|
|
4
4
|
export declare abstract class APC implements IClear, PCLike {
|
|
5
5
|
attribs?: Attribs | undefined;
|
|
6
6
|
points: Vec[];
|
|
7
7
|
constructor(points?: Iterable<Vec>, attribs?: Attribs | undefined);
|
|
8
8
|
abstract get type(): number | string;
|
|
9
|
+
abstract get dim(): number;
|
|
9
10
|
abstract copy(): APC;
|
|
11
|
+
abstract copyTransformed(fn: Fn<ReadonlyVec[], Vec[]>): APC;
|
|
10
12
|
abstract withAttribs(attribs: Attribs): APC;
|
|
11
13
|
[Symbol.iterator](): Generator<Vec, void, undefined>;
|
|
12
14
|
clear(): void;
|
package/api/arc.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Attribs, IHiccupPathSegment, IHiccupShape } from "@thi.ng/geom-api";
|
|
2
1
|
import type { Vec } from "@thi.ng/vectors";
|
|
3
|
-
|
|
2
|
+
import type { Attribs, HiccupPathSegment, IHiccupPathSegment, IHiccupShape2 } from "../api.js";
|
|
3
|
+
export declare class Arc implements IHiccupShape2<Arc>, IHiccupPathSegment {
|
|
4
4
|
pos: Vec;
|
|
5
5
|
r: Vec;
|
|
6
6
|
axis: number;
|
|
@@ -9,14 +9,15 @@ export declare class Arc implements IHiccupShape, IHiccupPathSegment {
|
|
|
9
9
|
xl: boolean;
|
|
10
10
|
cw: boolean;
|
|
11
11
|
attribs?: Attribs | undefined;
|
|
12
|
+
readonly type = "arc";
|
|
13
|
+
readonly dim = 2;
|
|
12
14
|
constructor(pos: Vec, r: Vec, axis: number, start: number, end: number, xl?: boolean, cw?: boolean, attribs?: Attribs | undefined);
|
|
13
|
-
get type(): string;
|
|
14
15
|
copy(): Arc;
|
|
15
16
|
withAttribs(attribs: Attribs): Arc;
|
|
16
17
|
equiv(o: any): boolean;
|
|
17
18
|
pointAt(t: number, out?: Vec): Vec;
|
|
18
19
|
pointAtTheta(theta: number, out?: Vec): Vec;
|
|
19
|
-
toHiccup(): (string | Attribs | (
|
|
20
|
-
toHiccupPathSegments():
|
|
20
|
+
toHiccup(): (string | Attribs | (HiccupPathSegment | (string | Vec)[])[] | undefined)[];
|
|
21
|
+
toHiccupPathSegments(): HiccupPathSegment[];
|
|
21
22
|
}
|
|
22
23
|
//# sourceMappingURL=arc.d.ts.map
|
package/api/arc.js
CHANGED
|
@@ -16,9 +16,8 @@ class Arc {
|
|
|
16
16
|
this.cw = cw;
|
|
17
17
|
this.attribs = attribs;
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
19
|
+
type = "arc";
|
|
20
|
+
dim = 2;
|
|
22
21
|
copy() {
|
|
23
22
|
return new Arc(
|
|
24
23
|
set([], this.pos),
|
|
@@ -28,7 +27,7 @@ class Arc {
|
|
|
28
27
|
this.end,
|
|
29
28
|
this.xl,
|
|
30
29
|
this.cw,
|
|
31
|
-
__copyAttribs(this)
|
|
30
|
+
__copyAttribs(this.attribs)
|
|
32
31
|
);
|
|
33
32
|
}
|
|
34
33
|
withAttribs(attribs) {
|
package/api/bpatch.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Fn } from "@thi.ng/api";
|
|
2
2
|
import type { ReadonlyVec, Vec, VecPair } from "@thi.ng/vectors";
|
|
3
|
+
import type { Attribs, IHiccupShape2 } from "../api.js";
|
|
3
4
|
import { APC } from "./apc.js";
|
|
4
5
|
/**
|
|
5
6
|
* nD Cubic bezier patch defined by array of 4x4 control points in this
|
|
@@ -27,10 +28,12 @@ import { APC } from "./apc.js";
|
|
|
27
28
|
* Ported from toxiclibs.
|
|
28
29
|
*
|
|
29
30
|
*/
|
|
30
|
-
export declare class BPatch extends APC implements
|
|
31
|
+
export declare class BPatch extends APC implements IHiccupShape2<BPatch> {
|
|
32
|
+
readonly type = "bpatch";
|
|
33
|
+
readonly dim = 2;
|
|
31
34
|
constructor(points: Iterable<Vec>, attribs?: Attribs);
|
|
32
|
-
get type(): string;
|
|
33
35
|
copy(): BPatch;
|
|
36
|
+
copyTransformed(fn: Fn<ReadonlyVec[], Vec[]>): BPatch;
|
|
34
37
|
withAttribs(attribs: Attribs): BPatch;
|
|
35
38
|
edges(): VecPair[];
|
|
36
39
|
unmapPoint(uv: ReadonlyVec, out?: Vec): Vec;
|
package/api/bpatch.js
CHANGED
|
@@ -3,16 +3,18 @@ import { __copyShape } from "../internal/copy.js";
|
|
|
3
3
|
import { __ensureNumVerts } from "../internal/pclike.js";
|
|
4
4
|
import { APC } from "./apc.js";
|
|
5
5
|
class BPatch extends APC {
|
|
6
|
+
type = "bpatch";
|
|
7
|
+
dim = 2;
|
|
6
8
|
constructor(points, attribs) {
|
|
7
9
|
super(points, attribs);
|
|
8
10
|
__ensureNumVerts(this.points.length, 16);
|
|
9
11
|
}
|
|
10
|
-
get type() {
|
|
11
|
-
return "bpatch";
|
|
12
|
-
}
|
|
13
12
|
copy() {
|
|
14
13
|
return __copyShape(BPatch, this);
|
|
15
14
|
}
|
|
15
|
+
copyTransformed(fn) {
|
|
16
|
+
return __copyShape(BPatch, this, fn(this.points));
|
|
17
|
+
}
|
|
16
18
|
withAttribs(attribs) {
|
|
17
19
|
return new BPatch(this.points, attribs);
|
|
18
20
|
}
|
package/api/circle.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import type { Attribs, IHiccupShape } from "@thi.ng/geom-api";
|
|
2
1
|
import type { Vec } from "@thi.ng/vectors";
|
|
3
|
-
|
|
2
|
+
import type { Attribs, IHiccupShape2 } from "../api.js";
|
|
3
|
+
export declare class Circle implements IHiccupShape2<Circle> {
|
|
4
4
|
pos: Vec;
|
|
5
5
|
r: number;
|
|
6
6
|
attribs?: Attribs | undefined;
|
|
7
|
+
readonly type = "circle";
|
|
8
|
+
readonly dim = 2;
|
|
7
9
|
constructor(pos?: Vec, r?: number, attribs?: Attribs | undefined);
|
|
8
|
-
get type(): string;
|
|
9
10
|
copy(): Circle;
|
|
10
11
|
withAttribs(attribs: Attribs): Circle;
|
|
11
12
|
toHiccup(): (string | number | Vec | Attribs | undefined)[];
|
package/api/circle.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { set2 } from "@thi.ng/vectors/set";
|
|
2
2
|
import { __copyAttribs } from "../internal/copy.js";
|
|
3
3
|
class Circle {
|
|
4
4
|
constructor(pos = [0, 0], r = 1, attribs) {
|
|
@@ -6,17 +6,20 @@ class Circle {
|
|
|
6
6
|
this.r = r;
|
|
7
7
|
this.attribs = attribs;
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
9
|
+
type = "circle";
|
|
10
|
+
dim = 2;
|
|
12
11
|
copy() {
|
|
13
|
-
return new Circle(
|
|
12
|
+
return new Circle(
|
|
13
|
+
set2([], this.pos),
|
|
14
|
+
this.r,
|
|
15
|
+
__copyAttribs(this.attribs)
|
|
16
|
+
);
|
|
14
17
|
}
|
|
15
18
|
withAttribs(attribs) {
|
|
16
19
|
return new Circle(this.pos, this.r, attribs);
|
|
17
20
|
}
|
|
18
21
|
toHiccup() {
|
|
19
|
-
return [
|
|
22
|
+
return [this.type, this.attribs, this.pos, this.r];
|
|
20
23
|
}
|
|
21
24
|
}
|
|
22
25
|
export {
|
package/api/complex-polygon.d.ts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Fn } from "@thi.ng/api";
|
|
2
|
+
import type { Attribs, IHiccupShape2 } from "../api.js";
|
|
2
3
|
import { Polygon } from "./polygon.js";
|
|
3
|
-
export declare class ComplexPolygon implements
|
|
4
|
+
export declare class ComplexPolygon implements IHiccupShape2<ComplexPolygon> {
|
|
4
5
|
boundary: Polygon;
|
|
5
6
|
attribs?: Attribs | undefined;
|
|
7
|
+
readonly type = "complexpoly";
|
|
8
|
+
readonly dim = 2;
|
|
6
9
|
children: Polygon[];
|
|
7
10
|
constructor(boundary?: Polygon, children?: Iterable<Polygon>, attribs?: Attribs | undefined);
|
|
8
|
-
|
|
11
|
+
[Symbol.iterator](): Generator<Polygon, void, undefined>;
|
|
9
12
|
addChild(poly: Polygon): void;
|
|
10
13
|
copy(): ComplexPolygon;
|
|
14
|
+
copyTransformed(fn: Fn<Polygon, Polygon>): ComplexPolygon;
|
|
11
15
|
withAttribs(attribs: Attribs): ComplexPolygon;
|
|
12
16
|
toHiccup(): (string | any[] | Attribs | undefined)[];
|
|
13
17
|
}
|
package/api/complex-polygon.js
CHANGED
|
@@ -7,9 +7,12 @@ class ComplexPolygon {
|
|
|
7
7
|
this.attribs = attribs;
|
|
8
8
|
this.children = children ? ensureArray(children) : [];
|
|
9
9
|
}
|
|
10
|
+
type = "complexpoly";
|
|
11
|
+
dim = 2;
|
|
10
12
|
children;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
*[Symbol.iterator]() {
|
|
14
|
+
yield this.boundary;
|
|
15
|
+
yield* this.children;
|
|
13
16
|
}
|
|
14
17
|
addChild(poly) {
|
|
15
18
|
this.children.push(poly);
|
|
@@ -18,7 +21,14 @@ class ComplexPolygon {
|
|
|
18
21
|
return new ComplexPolygon(
|
|
19
22
|
this.boundary.copy(),
|
|
20
23
|
this.children.map((h) => h.copy()),
|
|
21
|
-
__copyAttribs(this)
|
|
24
|
+
__copyAttribs(this.attribs)
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
copyTransformed(fn) {
|
|
28
|
+
return new ComplexPolygon(
|
|
29
|
+
fn(this.boundary),
|
|
30
|
+
this.children.map((child) => fn(child)),
|
|
31
|
+
__copyAttribs(this.attribs)
|
|
22
32
|
);
|
|
23
33
|
}
|
|
24
34
|
withAttribs(attribs) {
|
|
@@ -32,7 +42,7 @@ class ComplexPolygon {
|
|
|
32
42
|
for (let i = 1, n = points.length; i < n; i++) {
|
|
33
43
|
segments.push(["L", points[i]]);
|
|
34
44
|
}
|
|
35
|
-
segments.push(["
|
|
45
|
+
segments.push(["z"]);
|
|
36
46
|
};
|
|
37
47
|
$hiccupSegments(this.boundary);
|
|
38
48
|
for (let c of this.children) $hiccupSegments(c);
|
package/api/cubic.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Vec } from "@thi.ng/vectors";
|
|
1
|
+
import type { Fn } from "@thi.ng/api";
|
|
2
|
+
import type { ReadonlyVec, Vec } from "@thi.ng/vectors";
|
|
3
|
+
import type { Attribs, HiccupPathSegment, IHiccupPathSegment, IHiccupShape2 } from "../api.js";
|
|
3
4
|
import { APC } from "./apc.js";
|
|
4
|
-
export declare class Cubic extends APC implements IHiccupPathSegment {
|
|
5
|
+
export declare class Cubic extends APC implements IHiccupShape2<Cubic>, IHiccupPathSegment {
|
|
6
|
+
readonly type = "cubic";
|
|
7
|
+
readonly dim = 2;
|
|
5
8
|
constructor(points: Iterable<Vec>, attribs?: Attribs);
|
|
6
|
-
get type(): string;
|
|
7
9
|
copy(): Cubic;
|
|
10
|
+
copyTransformed(fn: Fn<ReadonlyVec[], Vec[]>): Cubic;
|
|
8
11
|
withAttribs(attribs: Attribs): Cubic;
|
|
9
12
|
toHiccup(): (string | Attribs | (string | Vec)[][] | undefined)[];
|
|
10
|
-
toHiccupPathSegments():
|
|
13
|
+
toHiccupPathSegments(): HiccupPathSegment[];
|
|
11
14
|
}
|
|
12
15
|
//# sourceMappingURL=cubic.d.ts.map
|
package/api/cubic.js
CHANGED
|
@@ -2,29 +2,35 @@ import { __copyShape } from "../internal/copy.js";
|
|
|
2
2
|
import { __ensureNumVerts } from "../internal/pclike.js";
|
|
3
3
|
import { APC } from "./apc.js";
|
|
4
4
|
class Cubic extends APC {
|
|
5
|
+
type = "cubic";
|
|
6
|
+
dim = 2;
|
|
5
7
|
constructor(points, attribs) {
|
|
6
8
|
super(points, attribs);
|
|
7
9
|
__ensureNumVerts(this.points.length, 4);
|
|
8
10
|
}
|
|
9
|
-
get type() {
|
|
10
|
-
return "cubic";
|
|
11
|
-
}
|
|
12
11
|
copy() {
|
|
13
12
|
return __copyShape(Cubic, this);
|
|
14
13
|
}
|
|
14
|
+
copyTransformed(fn) {
|
|
15
|
+
return __copyShape(Cubic, this, fn(this.points));
|
|
16
|
+
}
|
|
15
17
|
withAttribs(attribs) {
|
|
16
18
|
return new Cubic(this.points, attribs);
|
|
17
19
|
}
|
|
18
20
|
toHiccup() {
|
|
21
|
+
const [a, b, c, d] = this.points;
|
|
19
22
|
return [
|
|
20
23
|
"path",
|
|
21
24
|
this.attribs,
|
|
22
|
-
[
|
|
25
|
+
[
|
|
26
|
+
["M", a],
|
|
27
|
+
["C", b, c, d]
|
|
28
|
+
]
|
|
23
29
|
];
|
|
24
30
|
}
|
|
25
31
|
toHiccupPathSegments() {
|
|
26
|
-
const
|
|
27
|
-
return [["C",
|
|
32
|
+
const [_, b, c, d] = this.points;
|
|
33
|
+
return [["C", b, c, d]];
|
|
28
34
|
}
|
|
29
35
|
}
|
|
30
36
|
export {
|
package/api/cubic3.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Fn } from "@thi.ng/api";
|
|
2
|
+
import type { ReadonlyVec, Vec } from "@thi.ng/vectors";
|
|
3
|
+
import type { Attribs, HiccupPathSegment, IHiccupPathSegment, IHiccupShape3 } from "../api.js";
|
|
4
|
+
import { APC } from "./apc.js";
|
|
5
|
+
export declare class Cubic3 extends APC implements IHiccupShape3<Cubic3>, IHiccupPathSegment {
|
|
6
|
+
readonly type = "cubic3";
|
|
7
|
+
readonly dim = 3;
|
|
8
|
+
constructor(points: Iterable<Vec>, attribs?: Attribs);
|
|
9
|
+
copy(): Cubic3;
|
|
10
|
+
copyTransformed(fn: Fn<ReadonlyVec[], Vec[]>): Cubic3;
|
|
11
|
+
withAttribs(attribs: Attribs): Cubic3;
|
|
12
|
+
toHiccup(): (string | Attribs | (string | Vec)[][] | undefined)[];
|
|
13
|
+
toHiccupPathSegments(): HiccupPathSegment[];
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=cubic3.d.ts.map
|
package/api/cubic3.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { __copyShape } from "../internal/copy.js";
|
|
2
|
+
import { __ensureNumVerts } from "../internal/pclike.js";
|
|
3
|
+
import { APC } from "./apc.js";
|
|
4
|
+
class Cubic3 extends APC {
|
|
5
|
+
type = "cubic3";
|
|
6
|
+
dim = 3;
|
|
7
|
+
constructor(points, attribs) {
|
|
8
|
+
super(points, attribs);
|
|
9
|
+
__ensureNumVerts(this.points.length, 4);
|
|
10
|
+
}
|
|
11
|
+
copy() {
|
|
12
|
+
return __copyShape(Cubic3, this);
|
|
13
|
+
}
|
|
14
|
+
copyTransformed(fn) {
|
|
15
|
+
return __copyShape(Cubic3, this, fn(this.points));
|
|
16
|
+
}
|
|
17
|
+
withAttribs(attribs) {
|
|
18
|
+
return new Cubic3(this.points, attribs);
|
|
19
|
+
}
|
|
20
|
+
toHiccup() {
|
|
21
|
+
const [a, b, c, d] = this.points;
|
|
22
|
+
return [
|
|
23
|
+
"path3",
|
|
24
|
+
this.attribs,
|
|
25
|
+
[
|
|
26
|
+
["M", a],
|
|
27
|
+
["C", b, c, d]
|
|
28
|
+
]
|
|
29
|
+
];
|
|
30
|
+
}
|
|
31
|
+
toHiccupPathSegments() {
|
|
32
|
+
const [_, b, c, d] = this.points;
|
|
33
|
+
return [["C", b, c, d]];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
Cubic3
|
|
38
|
+
};
|
package/api/ellipse.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import type { Attribs, IHiccupShape } from "@thi.ng/geom-api";
|
|
2
1
|
import type { Vec } from "@thi.ng/vectors";
|
|
3
|
-
|
|
2
|
+
import type { Attribs, IHiccupShape2 } from "../api.js";
|
|
3
|
+
export declare class Ellipse implements IHiccupShape2<Ellipse> {
|
|
4
4
|
pos: Vec;
|
|
5
5
|
attribs?: Attribs | undefined;
|
|
6
|
+
readonly type = "ellipse";
|
|
7
|
+
readonly dim = 2;
|
|
6
8
|
r: Vec;
|
|
7
9
|
constructor(pos?: Vec, r?: number | Vec, attribs?: Attribs | undefined);
|
|
8
|
-
get type(): string;
|
|
9
10
|
copy(): Ellipse;
|
|
10
11
|
withAttribs(attribs: Attribs): Ellipse;
|
|
11
12
|
toHiccup(): (string | Vec | Attribs | undefined)[];
|
package/api/ellipse.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { set2 } from "@thi.ng/vectors/set";
|
|
2
2
|
import { __asVec } from "../internal/args.js";
|
|
3
3
|
import { __copyAttribs } from "../internal/copy.js";
|
|
4
4
|
class Ellipse {
|
|
@@ -7,22 +7,21 @@ class Ellipse {
|
|
|
7
7
|
this.attribs = attribs;
|
|
8
8
|
this.r = __asVec(r);
|
|
9
9
|
}
|
|
10
|
+
type = "ellipse";
|
|
11
|
+
dim = 2;
|
|
10
12
|
r;
|
|
11
|
-
get type() {
|
|
12
|
-
return "ellipse";
|
|
13
|
-
}
|
|
14
13
|
copy() {
|
|
15
14
|
return new Ellipse(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
__copyAttribs(this)
|
|
15
|
+
set2([], this.pos),
|
|
16
|
+
set2([], this.r),
|
|
17
|
+
__copyAttribs(this.attribs)
|
|
19
18
|
);
|
|
20
19
|
}
|
|
21
20
|
withAttribs(attribs) {
|
|
22
21
|
return new Ellipse(this.pos, this.r, attribs);
|
|
23
22
|
}
|
|
24
23
|
toHiccup() {
|
|
25
|
-
return [
|
|
24
|
+
return [this.type, this.attribs, this.pos, this.r];
|
|
26
25
|
}
|
|
27
26
|
}
|
|
28
27
|
export {
|
package/api/extra.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { IHiccupShape2 } from "../api.js";
|
|
2
|
+
/**
|
|
3
|
+
* Dummy shape container for arbitrary hiccup elements. See {@link extra} for
|
|
4
|
+
* more details.
|
|
5
|
+
*/
|
|
6
|
+
export declare class Extra implements IHiccupShape2<Extra> {
|
|
7
|
+
body: any[];
|
|
8
|
+
readonly type = "extra";
|
|
9
|
+
readonly dim = 2;
|
|
10
|
+
constructor(body: any[]);
|
|
11
|
+
copy(): Extra;
|
|
12
|
+
withAttribs(): Extra;
|
|
13
|
+
toHiccup(): any[];
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=extra.d.ts.map
|
package/api/extra.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
class Extra {
|
|
2
|
+
constructor(body) {
|
|
3
|
+
this.body = body;
|
|
4
|
+
}
|
|
5
|
+
type = "extra";
|
|
6
|
+
dim = 2;
|
|
7
|
+
copy() {
|
|
8
|
+
return new Extra(this.body);
|
|
9
|
+
}
|
|
10
|
+
withAttribs() {
|
|
11
|
+
return this.copy();
|
|
12
|
+
}
|
|
13
|
+
toHiccup() {
|
|
14
|
+
return this.body;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
Extra
|
|
19
|
+
};
|
package/api/group.d.ts
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Attribs,
|
|
1
|
+
import type { FnU, IClear } from "@thi.ng/api";
|
|
2
|
+
import type { Attribs, GroupAttribs, IHiccupShape2 } from "../api.js";
|
|
3
3
|
/**
|
|
4
|
-
* Geometry/shape group container for other {@link
|
|
4
|
+
* Geometry/shape group container for other {@link IHiccupShape2}s, incl. nested
|
|
5
5
|
* groups.
|
|
6
6
|
*/
|
|
7
|
-
export declare class Group implements IClear,
|
|
8
|
-
attribs?:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
export declare class Group implements IClear, IHiccupShape2<Group> {
|
|
8
|
+
attribs?: GroupAttribs | undefined;
|
|
9
|
+
readonly type = "group";
|
|
10
|
+
readonly dim = 2;
|
|
11
|
+
children: IHiccupShape2[];
|
|
12
|
+
constructor(attribs?: GroupAttribs | undefined, children?: Iterable<IHiccupShape2>);
|
|
13
|
+
[Symbol.iterator](): Generator<IHiccupShape2, void, undefined>;
|
|
13
14
|
/**
|
|
14
15
|
* Appends given `shapes` to this {@link Group.children} array.
|
|
15
16
|
*
|
|
16
17
|
* @param shapes
|
|
17
18
|
*/
|
|
18
|
-
add(...shapes:
|
|
19
|
+
add(...shapes: IHiccupShape2[]): this;
|
|
19
20
|
/**
|
|
20
21
|
* Removes all children from the group.
|
|
21
22
|
*/
|
|
22
23
|
clear(): void;
|
|
23
24
|
copy(): Group;
|
|
24
|
-
copyTransformed(fn:
|
|
25
|
+
copyTransformed(fn: FnU<IHiccupShape2>): Group;
|
|
25
26
|
withAttribs(attribs: Attribs): Group;
|
|
26
27
|
equiv(o: any): boolean;
|
|
27
28
|
toHiccup(): any[];
|
package/api/group.js
CHANGED
|
@@ -6,10 +6,9 @@ class Group {
|
|
|
6
6
|
this.attribs = attribs;
|
|
7
7
|
this.children = children ? ensureArray(children) : [];
|
|
8
8
|
}
|
|
9
|
+
type = "group";
|
|
10
|
+
dim = 2;
|
|
9
11
|
children;
|
|
10
|
-
get type() {
|
|
11
|
-
return "group";
|
|
12
|
-
}
|
|
13
12
|
*[Symbol.iterator]() {
|
|
14
13
|
yield* this.children;
|
|
15
14
|
}
|
|
@@ -32,13 +31,13 @@ class Group {
|
|
|
32
31
|
return this.copyTransformed((c) => c.copy());
|
|
33
32
|
}
|
|
34
33
|
copyTransformed(fn) {
|
|
35
|
-
return new Group(__copyAttribs(this), this.children.map(fn));
|
|
34
|
+
return new Group(__copyAttribs(this.attribs), this.children.map(fn));
|
|
36
35
|
}
|
|
37
36
|
withAttribs(attribs) {
|
|
38
37
|
return new Group(attribs, this.children);
|
|
39
38
|
}
|
|
40
39
|
equiv(o) {
|
|
41
|
-
return o instanceof Group && equiv(this.children, o.children);
|
|
40
|
+
return o instanceof Group && equiv(this.attribs, o.attribs) && equiv(this.children, o.children);
|
|
42
41
|
}
|
|
43
42
|
toHiccup() {
|
|
44
43
|
return ["g", this.attribs, ...this.children.map((x) => x.toHiccup())];
|
package/api/group3.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { FnU, IClear } from "@thi.ng/api";
|
|
2
|
+
import type { Attribs, IHiccupShape3 } from "../api.js";
|
|
3
|
+
/**
|
|
4
|
+
* Geometry/shape group container for other {@link IHiccupShape3}s, incl. nested
|
|
5
|
+
* groups.
|
|
6
|
+
*/
|
|
7
|
+
export declare class Group3 implements IClear, IHiccupShape3<Group3> {
|
|
8
|
+
attribs?: Attribs | undefined;
|
|
9
|
+
readonly type = "group3";
|
|
10
|
+
readonly dim = 3;
|
|
11
|
+
children: IHiccupShape3[];
|
|
12
|
+
constructor(attribs?: Attribs | undefined, children?: Iterable<IHiccupShape3>);
|
|
13
|
+
[Symbol.iterator](): Generator<IHiccupShape3, void, undefined>;
|
|
14
|
+
/**
|
|
15
|
+
* Appends given `shapes` to this {@link Group.children} array.
|
|
16
|
+
*
|
|
17
|
+
* @param shapes
|
|
18
|
+
*/
|
|
19
|
+
add(...shapes: IHiccupShape3[]): this;
|
|
20
|
+
/**
|
|
21
|
+
* Removes all children from the group.
|
|
22
|
+
*/
|
|
23
|
+
clear(): void;
|
|
24
|
+
copy(): Group3;
|
|
25
|
+
copyTransformed(fn: FnU<IHiccupShape3>): Group3;
|
|
26
|
+
withAttribs(attribs: Attribs): Group3;
|
|
27
|
+
equiv(o: any): boolean;
|
|
28
|
+
toHiccup(): any[];
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=group3.d.ts.map
|