@thi.ng/geom 7.0.1 → 8.0.0
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 +190 -1
- package/README.md +349 -112
- 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 +54 -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 +35 -1
- package/index.js +35 -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/api/group3.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ensureArray } from "@thi.ng/arrays/ensure-array";
|
|
2
|
+
import { equiv } from "@thi.ng/equiv";
|
|
3
|
+
import { __copyAttribs } from "../internal/copy.js";
|
|
4
|
+
class Group3 {
|
|
5
|
+
constructor(attribs, children) {
|
|
6
|
+
this.attribs = attribs;
|
|
7
|
+
this.children = children ? ensureArray(children) : [];
|
|
8
|
+
}
|
|
9
|
+
type = "group3";
|
|
10
|
+
dim = 3;
|
|
11
|
+
children;
|
|
12
|
+
*[Symbol.iterator]() {
|
|
13
|
+
yield* this.children;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Appends given `shapes` to this {@link Group.children} array.
|
|
17
|
+
*
|
|
18
|
+
* @param shapes
|
|
19
|
+
*/
|
|
20
|
+
add(...shapes) {
|
|
21
|
+
this.children.push(...shapes);
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Removes all children from the group.
|
|
26
|
+
*/
|
|
27
|
+
clear() {
|
|
28
|
+
this.children.length = 0;
|
|
29
|
+
}
|
|
30
|
+
copy() {
|
|
31
|
+
return this.copyTransformed((c) => c.copy());
|
|
32
|
+
}
|
|
33
|
+
copyTransformed(fn) {
|
|
34
|
+
return new Group3(__copyAttribs(this.attribs), this.children.map(fn));
|
|
35
|
+
}
|
|
36
|
+
withAttribs(attribs) {
|
|
37
|
+
return new Group3(attribs, this.children);
|
|
38
|
+
}
|
|
39
|
+
equiv(o) {
|
|
40
|
+
return o instanceof Group3 && equiv(this.attribs, o.attribs) && equiv(this.children, o.children);
|
|
41
|
+
}
|
|
42
|
+
toHiccup() {
|
|
43
|
+
return ["g", this.attribs, ...this.children.map((x) => x.toHiccup())];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
Group3
|
|
48
|
+
};
|
package/api/line.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, IHiccupPathSegment, IHiccupShape2 } from "../api.js";
|
|
3
4
|
import { APC } from "./apc.js";
|
|
4
|
-
export declare class Line extends APC implements
|
|
5
|
+
export declare class Line extends APC implements IHiccupShape2<Line>, IHiccupPathSegment {
|
|
6
|
+
readonly type = "line";
|
|
7
|
+
readonly dim = 2;
|
|
5
8
|
constructor(points: Iterable<Vec>, attribs?: Attribs);
|
|
6
|
-
get type(): string;
|
|
7
9
|
copy(): Line;
|
|
10
|
+
copyTransformed(fn: Fn<ReadonlyVec[], Vec[]>): Line;
|
|
8
11
|
withAttribs(attribs: Attribs): Line;
|
|
9
12
|
toHiccup(): (string | Vec | Attribs | undefined)[];
|
|
10
|
-
toHiccupPathSegments(): (
|
|
13
|
+
toHiccupPathSegments(): import("../api.js").HiccupPathSegment[];
|
|
11
14
|
}
|
|
12
15
|
//# sourceMappingURL=line.d.ts.map
|
package/api/line.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import { __copyShape } from "../internal/copy.js";
|
|
2
2
|
import { __ensureNumVerts } from "../internal/pclike.js";
|
|
3
|
+
import { __hiccupLineSegment } from "../internal/vertices.js";
|
|
3
4
|
import { APC } from "./apc.js";
|
|
4
5
|
class Line extends APC {
|
|
6
|
+
type = "line";
|
|
7
|
+
dim = 2;
|
|
5
8
|
constructor(points, attribs) {
|
|
6
9
|
super(points, attribs);
|
|
7
10
|
__ensureNumVerts(this.points.length, 2);
|
|
8
11
|
}
|
|
9
|
-
get type() {
|
|
10
|
-
return "line";
|
|
11
|
-
}
|
|
12
12
|
copy() {
|
|
13
13
|
return __copyShape(Line, this);
|
|
14
14
|
}
|
|
15
|
+
copyTransformed(fn) {
|
|
16
|
+
return __copyShape(Line, this, fn(this.points));
|
|
17
|
+
}
|
|
15
18
|
withAttribs(attribs) {
|
|
16
19
|
return new Line(this.points, attribs);
|
|
17
20
|
}
|
|
18
21
|
toHiccup() {
|
|
19
|
-
return [
|
|
22
|
+
return [this.type, this.attribs, this.points[0], this.points[1]];
|
|
20
23
|
}
|
|
21
24
|
toHiccupPathSegments() {
|
|
22
|
-
|
|
23
|
-
return [
|
|
24
|
-
a[0] === b[0] ? ["V", b[1]] : a[1] === b[1] ? ["H", b[0]] : ["L", b]
|
|
25
|
-
];
|
|
25
|
+
return [__hiccupLineSegment(this.points[0], this.points[1])];
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
export {
|
package/api/line3.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 Line3 extends APC implements IHiccupShape3<Line3>, IHiccupPathSegment {
|
|
6
|
+
readonly type = "line3";
|
|
7
|
+
readonly dim = 3;
|
|
8
|
+
constructor(points: Iterable<Vec>, attribs?: Attribs);
|
|
9
|
+
copy(): Line3;
|
|
10
|
+
copyTransformed(fn: Fn<ReadonlyVec[], Vec[]>): Line3;
|
|
11
|
+
withAttribs(attribs: Attribs): Line3;
|
|
12
|
+
toHiccup(): (string | Vec | Attribs | undefined)[];
|
|
13
|
+
toHiccupPathSegments(): HiccupPathSegment[];
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=line3.d.ts.map
|
package/api/line3.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { __copyShape } from "../internal/copy.js";
|
|
2
|
+
import { __ensureNumVerts } from "../internal/pclike.js";
|
|
3
|
+
import { APC } from "./apc.js";
|
|
4
|
+
class Line3 extends APC {
|
|
5
|
+
type = "line3";
|
|
6
|
+
dim = 3;
|
|
7
|
+
constructor(points, attribs) {
|
|
8
|
+
super(points, attribs);
|
|
9
|
+
__ensureNumVerts(this.points.length, 2);
|
|
10
|
+
}
|
|
11
|
+
copy() {
|
|
12
|
+
return __copyShape(Line3, this);
|
|
13
|
+
}
|
|
14
|
+
copyTransformed(fn) {
|
|
15
|
+
return __copyShape(Line3, this, fn(this.points));
|
|
16
|
+
}
|
|
17
|
+
withAttribs(attribs) {
|
|
18
|
+
return new Line3(this.points, attribs);
|
|
19
|
+
}
|
|
20
|
+
toHiccup() {
|
|
21
|
+
return [this.type, this.attribs, this.points[0], this.points[1]];
|
|
22
|
+
}
|
|
23
|
+
toHiccupPathSegments() {
|
|
24
|
+
return [["L", this.points[1]]];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
Line3
|
|
29
|
+
};
|
package/api/path.d.ts
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
|
-
import type { IClear } from "@thi.ng/api";
|
|
2
|
-
import type { Attribs,
|
|
3
|
-
export declare class Path implements IClear,
|
|
1
|
+
import type { Fn, IClear, IEmpty } from "@thi.ng/api";
|
|
2
|
+
import type { Attribs, IHiccupShape2, IPath, PathSegment2 } from "../api.js";
|
|
3
|
+
export declare class Path implements IClear, IEmpty<Path>, IHiccupShape2<Path>, IPath<PathSegment2> {
|
|
4
4
|
attribs?: Attribs | undefined;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
readonly type = "path";
|
|
6
|
+
readonly dim = 2;
|
|
7
|
+
segments: PathSegment2[];
|
|
8
|
+
subPaths: PathSegment2[][];
|
|
9
|
+
constructor(segments?: Iterable<PathSegment2>, subPaths?: Iterable<PathSegment2[]>, attribs?: Attribs | undefined);
|
|
9
10
|
/**
|
|
10
11
|
* Returns true, if the last main segment is a closing segment, e.g. if the
|
|
11
12
|
* path represents a closed shape.
|
|
12
13
|
*/
|
|
13
14
|
get closed(): boolean;
|
|
14
|
-
[Symbol.iterator](): Generator<
|
|
15
|
+
[Symbol.iterator](): Generator<PathSegment2, void, undefined>;
|
|
15
16
|
clear(): void;
|
|
17
|
+
empty(): Path;
|
|
16
18
|
close(): this;
|
|
17
19
|
copy(): Path;
|
|
20
|
+
copyTransformed(fn: Fn<PathSegment2[], PathSegment2[]>): Path;
|
|
18
21
|
withAttribs(attribs: Attribs): Path;
|
|
19
22
|
equiv(o: any): boolean;
|
|
20
|
-
isComplex():
|
|
21
|
-
addSegments(...segments:
|
|
22
|
-
addSubPaths(...paths:
|
|
23
|
+
isComplex(): boolean;
|
|
24
|
+
addSegments(...segments: PathSegment2[]): this;
|
|
25
|
+
addSubPaths(...paths: PathSegment2[][]): this;
|
|
23
26
|
toHiccup(): (string | any[] | Attribs)[];
|
|
24
27
|
}
|
|
25
28
|
//# sourceMappingURL=path.d.ts.map
|
package/api/path.js
CHANGED
|
@@ -2,19 +2,18 @@ import { ensureArray } from "@thi.ng/arrays/ensure-array";
|
|
|
2
2
|
import { peek } from "@thi.ng/arrays/peek";
|
|
3
3
|
import { equiv } from "@thi.ng/equiv";
|
|
4
4
|
import { illegalState } from "@thi.ng/errors/illegal-state";
|
|
5
|
+
import { flatten1 } from "@thi.ng/transducers/flatten1";
|
|
5
6
|
import { __copyAttribs, __copySegment } from "../internal/copy.js";
|
|
6
|
-
const CLOSE = Object.freeze({ type: "z" });
|
|
7
7
|
class Path {
|
|
8
8
|
constructor(segments, subPaths, attribs) {
|
|
9
9
|
this.attribs = attribs;
|
|
10
10
|
this.segments = segments ? ensureArray(segments) : [];
|
|
11
11
|
this.subPaths = subPaths ? ensureArray(subPaths) : [];
|
|
12
12
|
}
|
|
13
|
+
type = "path";
|
|
14
|
+
dim = 2;
|
|
13
15
|
segments;
|
|
14
16
|
subPaths;
|
|
15
|
-
get type() {
|
|
16
|
-
return "path";
|
|
17
|
-
}
|
|
18
17
|
/**
|
|
19
18
|
* Returns true, if the last main segment is a closing segment, e.g. if the
|
|
20
19
|
* path represents a closed shape.
|
|
@@ -24,30 +23,36 @@ class Path {
|
|
|
24
23
|
}
|
|
25
24
|
*[Symbol.iterator]() {
|
|
26
25
|
yield* this.segments;
|
|
26
|
+
yield* flatten1(this.subPaths);
|
|
27
27
|
}
|
|
28
28
|
clear() {
|
|
29
29
|
this.segments.length = 0;
|
|
30
30
|
}
|
|
31
|
+
empty() {
|
|
32
|
+
return new Path();
|
|
33
|
+
}
|
|
31
34
|
close() {
|
|
32
|
-
if (!this.closed) this.segments.push(
|
|
35
|
+
if (!this.closed) this.segments.push({ type: "z" });
|
|
33
36
|
return this;
|
|
34
37
|
}
|
|
35
38
|
copy() {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
return this.copyTransformed((segments) => segments.map(__copySegment));
|
|
40
|
+
}
|
|
41
|
+
copyTransformed(fn) {
|
|
42
|
+
return new Path(
|
|
43
|
+
fn(this.segments),
|
|
44
|
+
this.subPaths.map(fn),
|
|
45
|
+
__copyAttribs(this.attribs)
|
|
40
46
|
);
|
|
41
|
-
return p;
|
|
42
47
|
}
|
|
43
48
|
withAttribs(attribs) {
|
|
44
49
|
return new Path(this.segments, this.subPaths, attribs);
|
|
45
50
|
}
|
|
46
51
|
equiv(o) {
|
|
47
|
-
return o instanceof Path && equiv(this.segments, o.segments);
|
|
52
|
+
return o instanceof Path && equiv(this.segments, o.segments) && equiv(this.subPaths, o.subPaths);
|
|
48
53
|
}
|
|
49
54
|
isComplex() {
|
|
50
|
-
return this.subPaths.length;
|
|
55
|
+
return !!this.subPaths.length;
|
|
51
56
|
}
|
|
52
57
|
addSegments(...segments) {
|
|
53
58
|
for (let s of segments) {
|
package/api/path3.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Fn, IClear, IEmpty } from "@thi.ng/api";
|
|
2
|
+
import type { Attribs, IHiccupShape3, IPath, PathSegment3 } from "../api.js";
|
|
3
|
+
export declare class Path3 implements IClear, IEmpty<Path3>, IHiccupShape3<Path3>, IPath<PathSegment3> {
|
|
4
|
+
attribs?: Attribs | undefined;
|
|
5
|
+
readonly type = "path3";
|
|
6
|
+
readonly dim = 3;
|
|
7
|
+
segments: PathSegment3[];
|
|
8
|
+
subPaths: PathSegment3[][];
|
|
9
|
+
constructor(segments?: Iterable<PathSegment3>, subPaths?: Iterable<PathSegment3[]>, attribs?: Attribs | undefined);
|
|
10
|
+
/**
|
|
11
|
+
* Returns true, if the last main segment is a closing segment, e.g. if the
|
|
12
|
+
* path represents a closed shape.
|
|
13
|
+
*/
|
|
14
|
+
get closed(): boolean;
|
|
15
|
+
[Symbol.iterator](): Generator<PathSegment3, void, undefined>;
|
|
16
|
+
clear(): void;
|
|
17
|
+
empty(): Path3;
|
|
18
|
+
close(): this;
|
|
19
|
+
copy(): Path3;
|
|
20
|
+
copyTransformed(fn: Fn<PathSegment3[], PathSegment3[]>): Path3;
|
|
21
|
+
withAttribs(attribs: Attribs): Path3;
|
|
22
|
+
equiv(o: any): boolean;
|
|
23
|
+
isComplex(): boolean;
|
|
24
|
+
addSegments(...segments: PathSegment3[]): this;
|
|
25
|
+
addSubPaths(...paths: PathSegment3[][]): this;
|
|
26
|
+
toHiccup(): (string | any[] | Attribs)[];
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=path3.d.ts.map
|
package/api/path3.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { ensureArray } from "@thi.ng/arrays/ensure-array";
|
|
2
|
+
import { peek } from "@thi.ng/arrays/peek";
|
|
3
|
+
import { equiv } from "@thi.ng/equiv";
|
|
4
|
+
import { illegalState } from "@thi.ng/errors/illegal-state";
|
|
5
|
+
import { flatten1 } from "@thi.ng/transducers/flatten1";
|
|
6
|
+
import { __copyAttribs, __copySegment } from "../internal/copy.js";
|
|
7
|
+
class Path3 {
|
|
8
|
+
constructor(segments, subPaths, attribs) {
|
|
9
|
+
this.attribs = attribs;
|
|
10
|
+
this.segments = segments ? ensureArray(segments) : [];
|
|
11
|
+
this.subPaths = subPaths ? ensureArray(subPaths) : [];
|
|
12
|
+
}
|
|
13
|
+
type = "path3";
|
|
14
|
+
dim = 3;
|
|
15
|
+
segments;
|
|
16
|
+
subPaths;
|
|
17
|
+
/**
|
|
18
|
+
* Returns true, if the last main segment is a closing segment, e.g. if the
|
|
19
|
+
* path represents a closed shape.
|
|
20
|
+
*/
|
|
21
|
+
get closed() {
|
|
22
|
+
return peek(this.segments)?.type === "z";
|
|
23
|
+
}
|
|
24
|
+
*[Symbol.iterator]() {
|
|
25
|
+
yield* this.segments;
|
|
26
|
+
yield* flatten1(this.subPaths);
|
|
27
|
+
}
|
|
28
|
+
clear() {
|
|
29
|
+
this.segments.length = 0;
|
|
30
|
+
}
|
|
31
|
+
empty() {
|
|
32
|
+
return new Path3();
|
|
33
|
+
}
|
|
34
|
+
close() {
|
|
35
|
+
if (!this.closed) this.segments.push({ type: "z" });
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
copy() {
|
|
39
|
+
return this.copyTransformed((segments) => segments.map(__copySegment));
|
|
40
|
+
}
|
|
41
|
+
copyTransformed(fn) {
|
|
42
|
+
return new Path3(
|
|
43
|
+
fn(this.segments),
|
|
44
|
+
this.subPaths.map(fn),
|
|
45
|
+
__copyAttribs(this.attribs)
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
withAttribs(attribs) {
|
|
49
|
+
return new Path3(this.segments, this.subPaths, attribs);
|
|
50
|
+
}
|
|
51
|
+
equiv(o) {
|
|
52
|
+
return o instanceof Path3 && equiv(this.segments, o.segments) && equiv(this.subPaths, o.subPaths);
|
|
53
|
+
}
|
|
54
|
+
isComplex() {
|
|
55
|
+
return !!this.subPaths.length;
|
|
56
|
+
}
|
|
57
|
+
addSegments(...segments) {
|
|
58
|
+
for (let s of segments) {
|
|
59
|
+
this.closed && illegalState("path already closed");
|
|
60
|
+
this.segments.push(s);
|
|
61
|
+
}
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
addSubPaths(...paths) {
|
|
65
|
+
this.subPaths.push(...paths);
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
toHiccup() {
|
|
69
|
+
const acc = [];
|
|
70
|
+
const $hiccupSegments = (segments) => {
|
|
71
|
+
for (let i = 0, n = segments.length; i < n; i++) {
|
|
72
|
+
const s = segments[i];
|
|
73
|
+
if (s.geo) {
|
|
74
|
+
acc.push(...s.geo.toHiccupPathSegments());
|
|
75
|
+
} else if (s.point) {
|
|
76
|
+
acc.push(["M", s.point]);
|
|
77
|
+
} else {
|
|
78
|
+
acc.push([s.type]);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
if (this.segments.length > 1) {
|
|
83
|
+
$hiccupSegments(this.segments);
|
|
84
|
+
}
|
|
85
|
+
for (let p of this.subPaths) $hiccupSegments(p);
|
|
86
|
+
return ["path3", this.attribs || {}, acc];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
export {
|
|
90
|
+
Path3
|
|
91
|
+
};
|
package/api/plane.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, IHiccupShape3 } from "../api.js";
|
|
3
|
+
export declare class Plane implements IHiccupShape3<Plane> {
|
|
4
4
|
normal: Vec;
|
|
5
5
|
w: number;
|
|
6
6
|
attribs?: Attribs | undefined;
|
|
7
|
+
readonly type = "plane";
|
|
8
|
+
readonly dim = 3;
|
|
7
9
|
constructor(normal?: Vec, w?: number, attribs?: Attribs | undefined);
|
|
8
|
-
get type(): string;
|
|
9
10
|
copy(): Plane;
|
|
10
11
|
withAttribs(attribs: Attribs): Plane;
|
|
11
12
|
toHiccup(): (string | number | Vec | Attribs | undefined)[];
|
package/api/plane.js
CHANGED
|
@@ -6,11 +6,14 @@ class Plane {
|
|
|
6
6
|
this.w = w;
|
|
7
7
|
this.attribs = attribs;
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
9
|
+
type = "plane";
|
|
10
|
+
dim = 3;
|
|
12
11
|
copy() {
|
|
13
|
-
return new Plane(
|
|
12
|
+
return new Plane(
|
|
13
|
+
set3([], this.normal),
|
|
14
|
+
this.w,
|
|
15
|
+
__copyAttribs(this.attribs)
|
|
16
|
+
);
|
|
14
17
|
}
|
|
15
18
|
withAttribs(attribs) {
|
|
16
19
|
return new Plane(this.normal, this.w, attribs);
|
package/api/points.d.ts
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Fn } from "@thi.ng/api";
|
|
2
|
+
import type { ReadonlyVec, Vec } from "@thi.ng/vectors";
|
|
3
|
+
import type { Attribs, IHiccupShape2 } from "../api.js";
|
|
2
4
|
import { APC } from "./apc.js";
|
|
3
|
-
export declare class Points extends APC implements
|
|
4
|
-
|
|
5
|
+
export declare class Points extends APC implements IHiccupShape2<Points> {
|
|
6
|
+
readonly type = "points";
|
|
7
|
+
readonly dim = 2;
|
|
5
8
|
copy(): Points;
|
|
9
|
+
copyTransformed(fn: Fn<ReadonlyVec[], Vec[]>): Points;
|
|
6
10
|
withAttribs(attribs: Attribs): Points;
|
|
7
|
-
toHiccup(): (string |
|
|
8
|
-
}
|
|
9
|
-
export declare class Points3 extends APC implements IHiccupShape {
|
|
10
|
-
get type(): string;
|
|
11
|
-
copy(): Points3;
|
|
12
|
-
withAttribs(attribs: Attribs): Points3;
|
|
13
|
-
toHiccup(): (string | import("@thi.ng/vectors").Vec[] | Attribs | undefined)[];
|
|
11
|
+
toHiccup(): (string | Vec[] | Attribs | undefined)[];
|
|
14
12
|
}
|
|
15
13
|
//# sourceMappingURL=points.d.ts.map
|
package/api/points.js
CHANGED
|
@@ -1,34 +1,21 @@
|
|
|
1
1
|
import { __copyShape } from "../internal/copy.js";
|
|
2
2
|
import { APC } from "./apc.js";
|
|
3
3
|
class Points extends APC {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
4
|
+
type = "points";
|
|
5
|
+
dim = 2;
|
|
7
6
|
copy() {
|
|
8
7
|
return __copyShape(Points, this);
|
|
9
8
|
}
|
|
10
|
-
|
|
11
|
-
return
|
|
12
|
-
}
|
|
13
|
-
toHiccup() {
|
|
14
|
-
return ["points", this.attribs, this.points];
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
class Points3 extends APC {
|
|
18
|
-
get type() {
|
|
19
|
-
return "points3";
|
|
20
|
-
}
|
|
21
|
-
copy() {
|
|
22
|
-
return __copyShape(Points3, this);
|
|
9
|
+
copyTransformed(fn) {
|
|
10
|
+
return __copyShape(Points, this, fn(this.points));
|
|
23
11
|
}
|
|
24
12
|
withAttribs(attribs) {
|
|
25
|
-
return new
|
|
13
|
+
return new Points(this.points, attribs);
|
|
26
14
|
}
|
|
27
15
|
toHiccup() {
|
|
28
|
-
return [
|
|
16
|
+
return [this.type, this.attribs, this.points];
|
|
29
17
|
}
|
|
30
18
|
}
|
|
31
19
|
export {
|
|
32
|
-
Points
|
|
33
|
-
Points3
|
|
20
|
+
Points
|
|
34
21
|
};
|
package/api/points3.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Fn } from "@thi.ng/api";
|
|
2
|
+
import type { ReadonlyVec, Vec } from "@thi.ng/vectors";
|
|
3
|
+
import type { Attribs, IHiccupShape3 } from "../api.js";
|
|
4
|
+
import { APC } from "./apc.js";
|
|
5
|
+
export declare class Points3 extends APC implements IHiccupShape3<Points3> {
|
|
6
|
+
readonly type = "points3";
|
|
7
|
+
readonly dim = 3;
|
|
8
|
+
copy(): Points3;
|
|
9
|
+
copyTransformed(fn: Fn<ReadonlyVec[], Vec[]>): Points3;
|
|
10
|
+
withAttribs(attribs: Attribs): Points3;
|
|
11
|
+
toHiccup(): (string | Vec[] | Attribs | undefined)[];
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=points3.d.ts.map
|
package/api/points3.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { __copyShape } from "../internal/copy.js";
|
|
2
|
+
import { APC } from "./apc.js";
|
|
3
|
+
class Points3 extends APC {
|
|
4
|
+
type = "points3";
|
|
5
|
+
dim = 3;
|
|
6
|
+
copy() {
|
|
7
|
+
return __copyShape(Points3, this);
|
|
8
|
+
}
|
|
9
|
+
copyTransformed(fn) {
|
|
10
|
+
return __copyShape(Points3, this, fn(this.points));
|
|
11
|
+
}
|
|
12
|
+
withAttribs(attribs) {
|
|
13
|
+
return new Points3(this.points, attribs);
|
|
14
|
+
}
|
|
15
|
+
toHiccup() {
|
|
16
|
+
return [this.type, this.attribs, this.points];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
Points3
|
|
21
|
+
};
|
package/api/polygon.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
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, IHiccupShape2 } from "../api.js";
|
|
3
4
|
import { APC } from "./apc.js";
|
|
4
|
-
export declare class Polygon extends APC implements
|
|
5
|
-
|
|
5
|
+
export declare class Polygon extends APC implements IHiccupShape2<Polygon> {
|
|
6
|
+
readonly type = "poly";
|
|
7
|
+
readonly dim = 2;
|
|
6
8
|
add(...points: Vec[]): void;
|
|
7
9
|
copy(): Polygon;
|
|
10
|
+
copyTransformed(fn: Fn<ReadonlyVec[], Vec[]>): Polygon;
|
|
8
11
|
withAttribs(attribs: Attribs): Polygon;
|
|
9
12
|
toHiccup(): (string | Vec[] | Attribs | undefined)[];
|
|
10
13
|
}
|
package/api/polygon.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { __copyShape } from "../internal/copy.js";
|
|
2
2
|
import { APC } from "./apc.js";
|
|
3
3
|
class Polygon extends APC {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
4
|
+
type = "poly";
|
|
5
|
+
dim = 2;
|
|
7
6
|
add(...points) {
|
|
8
7
|
this.points.push(...points);
|
|
9
8
|
}
|
|
10
9
|
copy() {
|
|
11
10
|
return __copyShape(Polygon, this);
|
|
12
11
|
}
|
|
12
|
+
copyTransformed(fn) {
|
|
13
|
+
return __copyShape(Polygon, this, fn(this.points));
|
|
14
|
+
}
|
|
13
15
|
withAttribs(attribs) {
|
|
14
16
|
return new Polygon(this.points, attribs);
|
|
15
17
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Fn } from "@thi.ng/api";
|
|
2
|
+
import type { ReadonlyVec, Vec } from "@thi.ng/vectors";
|
|
3
|
+
import type { Attribs, IHiccupShape3 } from "../api.js";
|
|
4
|
+
import { APC } from "./apc.js";
|
|
5
|
+
export declare class Polygon3 extends APC implements IHiccupShape3<Polygon3> {
|
|
6
|
+
readonly type = "poly3";
|
|
7
|
+
readonly dim = 3;
|
|
8
|
+
add(...points: Vec[]): void;
|
|
9
|
+
copy(): Polygon3;
|
|
10
|
+
copyTransformed(fn: Fn<ReadonlyVec[], Vec[]>): Polygon3;
|
|
11
|
+
withAttribs(attribs: Attribs): Polygon3;
|
|
12
|
+
toHiccup(): (string | Vec[] | Attribs | undefined)[];
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=polygon3.d.ts.map
|
package/api/polygon3.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { __copyShape } from "../internal/copy.js";
|
|
2
|
+
import { APC } from "./apc.js";
|
|
3
|
+
class Polygon3 extends APC {
|
|
4
|
+
type = "poly3";
|
|
5
|
+
dim = 3;
|
|
6
|
+
add(...points) {
|
|
7
|
+
this.points.push(...points);
|
|
8
|
+
}
|
|
9
|
+
copy() {
|
|
10
|
+
return __copyShape(Polygon3, this);
|
|
11
|
+
}
|
|
12
|
+
copyTransformed(fn) {
|
|
13
|
+
return __copyShape(Polygon3, this, fn(this.points));
|
|
14
|
+
}
|
|
15
|
+
withAttribs(attribs) {
|
|
16
|
+
return new Polygon3(this.points, attribs);
|
|
17
|
+
}
|
|
18
|
+
toHiccup() {
|
|
19
|
+
return ["polygon3", this.attribs, this.points];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
Polygon3
|
|
24
|
+
};
|
package/api/polyline.d.ts
CHANGED
|
@@ -1,13 +1,27 @@
|
|
|
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, IHiccupPathSegment, IHiccupShape2 } from "../api.js";
|
|
3
4
|
import { APC } from "./apc.js";
|
|
4
|
-
export declare class Polyline extends APC implements
|
|
5
|
-
|
|
5
|
+
export declare class Polyline extends APC implements IHiccupShape2<Polyline>, IHiccupPathSegment {
|
|
6
|
+
readonly type = "polyline";
|
|
7
|
+
readonly dim = 2;
|
|
6
8
|
add(...points: Vec[]): void;
|
|
7
9
|
copy(): Polyline;
|
|
10
|
+
copyTransformed(fn: Fn<ReadonlyVec[], Vec[]>): Polyline;
|
|
8
11
|
withAttribs(attribs: Attribs): Polyline;
|
|
9
12
|
toHiccup(): (string | Vec[] | {
|
|
10
13
|
fill: string;
|
|
14
|
+
__samples?: Partial<import("../api.js").SamplingOpts> | number;
|
|
15
|
+
__prec?: number;
|
|
16
|
+
rotate?: number;
|
|
17
|
+
rotateX?: number;
|
|
18
|
+
rotateY?: number;
|
|
19
|
+
rotateZ?: number;
|
|
20
|
+
scale?: number | ReadonlyVec;
|
|
21
|
+
translate?: ReadonlyVec;
|
|
22
|
+
transform?: ReadonlyVec;
|
|
23
|
+
stroke?: any;
|
|
24
|
+
weight?: number;
|
|
11
25
|
})[];
|
|
12
26
|
toHiccupPathSegments(): any[];
|
|
13
27
|
}
|
package/api/polyline.js
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
import { __copyShape } from "../internal/copy.js";
|
|
2
|
+
import { __hiccupLineSegment } from "../internal/vertices.js";
|
|
2
3
|
import { APC } from "./apc.js";
|
|
3
4
|
class Polyline extends APC {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
5
|
+
type = "polyline";
|
|
6
|
+
dim = 2;
|
|
7
7
|
add(...points) {
|
|
8
8
|
this.points.push(...points);
|
|
9
9
|
}
|
|
10
10
|
copy() {
|
|
11
11
|
return __copyShape(Polyline, this);
|
|
12
12
|
}
|
|
13
|
+
copyTransformed(fn) {
|
|
14
|
+
return __copyShape(Polyline, this, fn(this.points));
|
|
15
|
+
}
|
|
13
16
|
withAttribs(attribs) {
|
|
14
17
|
return new Polyline(this.points, attribs);
|
|
15
18
|
}
|
|
16
19
|
toHiccup() {
|
|
17
|
-
return [
|
|
20
|
+
return [this.type, { ...this.attribs, fill: "none" }, this.points];
|
|
18
21
|
}
|
|
19
22
|
toHiccupPathSegments() {
|
|
20
23
|
const res = [];
|
|
21
24
|
for (let pts = this.points, n = pts.length, i = 1; i < n; i++) {
|
|
22
|
-
res.push([
|
|
25
|
+
res.push(__hiccupLineSegment(pts[i - 1], pts[i]));
|
|
23
26
|
}
|
|
24
27
|
return res;
|
|
25
28
|
}
|