@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
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Fn } from "@thi.ng/api";
|
|
2
|
+
import type { ReadonlyVec, Vec } from "@thi.ng/vectors";
|
|
3
|
+
import type { Attribs, IHiccupPathSegment, IHiccupShape3 } from "../api.js";
|
|
4
|
+
import { APC } from "./apc.js";
|
|
5
|
+
export declare class Polyline3 extends APC implements IHiccupShape3<Polyline3>, IHiccupPathSegment {
|
|
6
|
+
readonly type = "polyline3";
|
|
7
|
+
readonly dim = 3;
|
|
8
|
+
add(...points: Vec[]): void;
|
|
9
|
+
copy(): Polyline3;
|
|
10
|
+
copyTransformed(fn: Fn<ReadonlyVec[], Vec[]>): Polyline3;
|
|
11
|
+
withAttribs(attribs: Attribs): Polyline3;
|
|
12
|
+
toHiccup(): (string | Vec[] | {
|
|
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;
|
|
25
|
+
})[];
|
|
26
|
+
toHiccupPathSegments(): any[];
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=polyline3.d.ts.map
|
package/api/polyline3.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { __copyShape } from "../internal/copy.js";
|
|
2
|
+
import { APC } from "./apc.js";
|
|
3
|
+
class Polyline3 extends APC {
|
|
4
|
+
type = "polyline3";
|
|
5
|
+
dim = 3;
|
|
6
|
+
add(...points) {
|
|
7
|
+
this.points.push(...points);
|
|
8
|
+
}
|
|
9
|
+
copy() {
|
|
10
|
+
return __copyShape(Polyline3, this);
|
|
11
|
+
}
|
|
12
|
+
copyTransformed(fn) {
|
|
13
|
+
return __copyShape(Polyline3, this, fn(this.points));
|
|
14
|
+
}
|
|
15
|
+
withAttribs(attribs) {
|
|
16
|
+
return new Polyline3(this.points, attribs);
|
|
17
|
+
}
|
|
18
|
+
toHiccup() {
|
|
19
|
+
return [this.type, { ...this.attribs, fill: "none" }, this.points];
|
|
20
|
+
}
|
|
21
|
+
toHiccupPathSegments() {
|
|
22
|
+
const res = [];
|
|
23
|
+
for (let pts = this.points, n = pts.length, i = 1; i < n; i++) {
|
|
24
|
+
res.push(["L", pts[i]]);
|
|
25
|
+
}
|
|
26
|
+
return res;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
Polyline3
|
|
31
|
+
};
|
package/api/quad.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 Quad extends APC implements
|
|
5
|
+
export declare class Quad extends APC implements IHiccupShape2<Quad> {
|
|
6
|
+
readonly type = "quad";
|
|
7
|
+
readonly dim = 2;
|
|
5
8
|
constructor(points: Iterable<Vec>, attribs?: Attribs);
|
|
6
|
-
get type(): string;
|
|
7
9
|
copy(): Quad;
|
|
10
|
+
copyTransformed(fn: Fn<ReadonlyVec[], Vec[]>): Quad;
|
|
8
11
|
withAttribs(attribs: Attribs): Quad;
|
|
9
12
|
toHiccup(): (string | Vec[] | Attribs | undefined)[];
|
|
10
13
|
}
|
package/api/quad.js
CHANGED
|
@@ -2,16 +2,18 @@ import { __copyShape } from "../internal/copy.js";
|
|
|
2
2
|
import { __ensureNumVerts } from "../internal/pclike.js";
|
|
3
3
|
import { APC } from "./apc.js";
|
|
4
4
|
class Quad extends APC {
|
|
5
|
+
type = "quad";
|
|
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 "quad";
|
|
11
|
-
}
|
|
12
11
|
copy() {
|
|
13
12
|
return __copyShape(Quad, this);
|
|
14
13
|
}
|
|
14
|
+
copyTransformed(fn) {
|
|
15
|
+
return __copyShape(Quad, this, fn(this.points));
|
|
16
|
+
}
|
|
15
17
|
withAttribs(attribs) {
|
|
16
18
|
return new Quad(this.points, attribs);
|
|
17
19
|
}
|
package/api/quad3.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, IHiccupShape3 } from "../api.js";
|
|
3
4
|
import { APC } from "./apc.js";
|
|
4
|
-
export declare class Quad3 extends APC implements
|
|
5
|
+
export declare class Quad3 extends APC implements IHiccupShape3<Quad3> {
|
|
6
|
+
readonly type = "quad3";
|
|
7
|
+
readonly dim = 3;
|
|
5
8
|
constructor(points: Iterable<Vec>, attribs?: Attribs);
|
|
6
|
-
get type(): string;
|
|
7
9
|
copy(): Quad3;
|
|
10
|
+
copyTransformed(fn: Fn<ReadonlyVec[], Vec[]>): Quad3;
|
|
8
11
|
withAttribs(attribs: Attribs): Quad3;
|
|
9
12
|
toHiccup(): (string | Vec[] | Attribs | undefined)[];
|
|
10
13
|
}
|
package/api/quad3.js
CHANGED
|
@@ -2,21 +2,23 @@ import { __copyShape } from "../internal/copy.js";
|
|
|
2
2
|
import { __ensureNumVerts } from "../internal/pclike.js";
|
|
3
3
|
import { APC } from "./apc.js";
|
|
4
4
|
class Quad3 extends APC {
|
|
5
|
+
type = "quad3";
|
|
6
|
+
dim = 3;
|
|
5
7
|
constructor(points, attribs) {
|
|
6
8
|
super(points, attribs);
|
|
7
9
|
__ensureNumVerts(this.points.length, 4);
|
|
8
10
|
}
|
|
9
|
-
get type() {
|
|
10
|
-
return "quad3";
|
|
11
|
-
}
|
|
12
11
|
copy() {
|
|
13
12
|
return __copyShape(Quad3, this);
|
|
14
13
|
}
|
|
14
|
+
copyTransformed(fn) {
|
|
15
|
+
return __copyShape(Quad3, this, fn(this.points));
|
|
16
|
+
}
|
|
15
17
|
withAttribs(attribs) {
|
|
16
18
|
return new Quad3(this.points, attribs);
|
|
17
19
|
}
|
|
18
20
|
toHiccup() {
|
|
19
|
-
return ["
|
|
21
|
+
return ["polygon3", this.attribs, this.points];
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
export {
|
package/api/quadratic.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 Quadratic extends APC implements
|
|
5
|
+
export declare class Quadratic extends APC implements IHiccupShape2<Quadratic>, IHiccupPathSegment {
|
|
6
|
+
readonly type = "quadratic";
|
|
7
|
+
readonly dim = 2;
|
|
5
8
|
constructor(points: Iterable<Vec>, attribs?: Attribs);
|
|
6
|
-
get type(): string;
|
|
7
9
|
copy(): Quadratic;
|
|
10
|
+
copyTransformed(fn: Fn<ReadonlyVec[], Vec[]>): Quadratic;
|
|
8
11
|
withAttribs(attribs: Attribs): Quadratic;
|
|
9
12
|
toHiccup(): (string | Attribs | (string | Vec)[][] | undefined)[];
|
|
10
|
-
toHiccupPathSegments():
|
|
13
|
+
toHiccupPathSegments(): HiccupPathSegment[];
|
|
11
14
|
}
|
|
12
15
|
//# sourceMappingURL=quadratic.d.ts.map
|
package/api/quadratic.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 Quadratic extends APC {
|
|
5
|
+
type = "quadratic";
|
|
6
|
+
dim = 2;
|
|
5
7
|
constructor(points, attribs) {
|
|
6
8
|
super(points, attribs);
|
|
7
9
|
__ensureNumVerts(this.points.length, 3);
|
|
8
10
|
}
|
|
9
|
-
get type() {
|
|
10
|
-
return "quadratic";
|
|
11
|
-
}
|
|
12
11
|
copy() {
|
|
13
12
|
return __copyShape(Quadratic, this);
|
|
14
13
|
}
|
|
14
|
+
copyTransformed(fn) {
|
|
15
|
+
return __copyShape(Quadratic, this, fn(this.points));
|
|
16
|
+
}
|
|
15
17
|
withAttribs(attribs) {
|
|
16
18
|
return new Quadratic(this.points, attribs);
|
|
17
19
|
}
|
|
18
20
|
toHiccup() {
|
|
21
|
+
const [a, b, c] = this.points;
|
|
19
22
|
return [
|
|
20
23
|
"path",
|
|
21
24
|
this.attribs,
|
|
22
|
-
[
|
|
25
|
+
[
|
|
26
|
+
["M", a],
|
|
27
|
+
["Q", b, c]
|
|
28
|
+
]
|
|
23
29
|
];
|
|
24
30
|
}
|
|
25
31
|
toHiccupPathSegments() {
|
|
26
|
-
const
|
|
27
|
-
return [["Q",
|
|
32
|
+
const [_, b, c] = this.points;
|
|
33
|
+
return [["Q", b, c]];
|
|
28
34
|
}
|
|
29
35
|
}
|
|
30
36
|
export {
|
|
@@ -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 Quadratic3 extends APC implements IHiccupShape3<Quadratic3>, IHiccupPathSegment {
|
|
6
|
+
readonly type = "quadratic3";
|
|
7
|
+
readonly dim = 3;
|
|
8
|
+
constructor(points: Iterable<Vec>, attribs?: Attribs);
|
|
9
|
+
copy(): Quadratic3;
|
|
10
|
+
copyTransformed(fn: Fn<ReadonlyVec[], Vec[]>): Quadratic3;
|
|
11
|
+
withAttribs(attribs: Attribs): Quadratic3;
|
|
12
|
+
toHiccup(): (string | Attribs | (string | Vec)[][] | undefined)[];
|
|
13
|
+
toHiccupPathSegments(): HiccupPathSegment[];
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=quadratic3.d.ts.map
|
|
@@ -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 Quadratic3 extends APC {
|
|
5
|
+
type = "quadratic3";
|
|
6
|
+
dim = 3;
|
|
7
|
+
constructor(points, attribs) {
|
|
8
|
+
super(points, attribs);
|
|
9
|
+
__ensureNumVerts(this.points.length, 3);
|
|
10
|
+
}
|
|
11
|
+
copy() {
|
|
12
|
+
return __copyShape(Quadratic3, this);
|
|
13
|
+
}
|
|
14
|
+
copyTransformed(fn) {
|
|
15
|
+
return __copyShape(Quadratic3, this, fn(this.points));
|
|
16
|
+
}
|
|
17
|
+
withAttribs(attribs) {
|
|
18
|
+
return new Quadratic3(this.points, attribs);
|
|
19
|
+
}
|
|
20
|
+
toHiccup() {
|
|
21
|
+
const [a, b, c] = this.points;
|
|
22
|
+
return [
|
|
23
|
+
"path3",
|
|
24
|
+
this.attribs,
|
|
25
|
+
[
|
|
26
|
+
["M", a],
|
|
27
|
+
["Q", b, c]
|
|
28
|
+
]
|
|
29
|
+
];
|
|
30
|
+
}
|
|
31
|
+
toHiccupPathSegments() {
|
|
32
|
+
const [_, b, c] = this.points;
|
|
33
|
+
return [["Q", b, c]];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
Quadratic3
|
|
38
|
+
};
|
package/api/ray.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 Ray implements IHiccupShape2<Ray> {
|
|
4
4
|
pos: Vec;
|
|
5
5
|
dir: Vec;
|
|
6
6
|
attribs?: Attribs | undefined;
|
|
7
|
+
readonly type = "ray";
|
|
8
|
+
readonly dim = 2;
|
|
7
9
|
constructor(pos: Vec, dir: Vec, attribs?: Attribs | undefined);
|
|
8
|
-
get type(): string;
|
|
9
10
|
copy(): Ray;
|
|
10
11
|
withAttribs(attribs: Attribs): Ray;
|
|
11
12
|
toHiccup(): (string | Vec | Attribs | undefined)[];
|
package/api/ray.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { maddN2 } from "@thi.ng/vectors/maddn";
|
|
2
|
-
import {
|
|
2
|
+
import { set2 } from "@thi.ng/vectors/set";
|
|
3
3
|
import { __copyAttribs } from "../internal/copy.js";
|
|
4
4
|
class Ray {
|
|
5
5
|
constructor(pos, dir, attribs) {
|
|
@@ -7,14 +7,13 @@ class Ray {
|
|
|
7
7
|
this.dir = dir;
|
|
8
8
|
this.attribs = attribs;
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
10
|
+
type = "ray";
|
|
11
|
+
dim = 2;
|
|
13
12
|
copy() {
|
|
14
13
|
return new Ray(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
__copyAttribs(this)
|
|
14
|
+
set2([], this.pos),
|
|
15
|
+
set2([], this.dir),
|
|
16
|
+
__copyAttribs(this.attribs)
|
|
18
17
|
);
|
|
19
18
|
}
|
|
20
19
|
withAttribs(attribs) {
|
package/api/ray3.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Vec } from "@thi.ng/vectors";
|
|
2
|
+
import type { Attribs, IHiccupShape3 } from "../api.js";
|
|
3
|
+
export declare class Ray3 implements IHiccupShape3<Ray3> {
|
|
4
|
+
pos: Vec;
|
|
5
|
+
dir: Vec;
|
|
6
|
+
attribs?: Attribs | undefined;
|
|
7
|
+
readonly type = "ray3";
|
|
8
|
+
readonly dim = 3;
|
|
9
|
+
constructor(pos: Vec, dir: Vec, attribs?: Attribs | undefined);
|
|
10
|
+
copy(): Ray3;
|
|
11
|
+
withAttribs(attribs: Attribs): Ray3;
|
|
12
|
+
toHiccup(): (string | Vec | Attribs | undefined)[];
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=ray3.d.ts.map
|
package/api/ray3.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { maddN3 } from "@thi.ng/vectors/maddn";
|
|
2
|
+
import { set3 } from "@thi.ng/vectors/set";
|
|
3
|
+
import { __copyAttribs } from "../internal/copy.js";
|
|
4
|
+
class Ray3 {
|
|
5
|
+
constructor(pos, dir, attribs) {
|
|
6
|
+
this.pos = pos;
|
|
7
|
+
this.dir = dir;
|
|
8
|
+
this.attribs = attribs;
|
|
9
|
+
}
|
|
10
|
+
type = "ray3";
|
|
11
|
+
dim = 3;
|
|
12
|
+
copy() {
|
|
13
|
+
return new Ray3(
|
|
14
|
+
set3([], this.pos),
|
|
15
|
+
set3([], this.dir),
|
|
16
|
+
__copyAttribs(this.attribs)
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
withAttribs(attribs) {
|
|
20
|
+
return new Ray3(this.pos, this.dir, attribs);
|
|
21
|
+
}
|
|
22
|
+
toHiccup() {
|
|
23
|
+
return [
|
|
24
|
+
"line3",
|
|
25
|
+
this.attribs,
|
|
26
|
+
this.pos,
|
|
27
|
+
maddN3([], this.dir, 1e6, this.pos)
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
Ray3
|
|
33
|
+
};
|
package/api/rect.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import type { AABBLike, Attribs, IHiccupShape } from "@thi.ng/geom-api";
|
|
2
1
|
import { type Vec } from "@thi.ng/vectors/api";
|
|
3
|
-
|
|
2
|
+
import type { AABBLike, Attribs, IHiccupShape2 } from "../api.js";
|
|
3
|
+
export declare class Rect implements AABBLike, IHiccupShape2<Rect> {
|
|
4
4
|
pos: Vec;
|
|
5
5
|
attribs?: Attribs | undefined;
|
|
6
|
+
readonly type = "rect";
|
|
7
|
+
readonly dim = 2;
|
|
6
8
|
size: Vec;
|
|
7
9
|
constructor(pos?: Vec, size?: number | Vec, attribs?: Attribs | undefined);
|
|
8
|
-
get type(): string;
|
|
9
10
|
copy(): Rect;
|
|
10
11
|
withAttribs(attribs: Attribs): Rect;
|
|
12
|
+
min(): Vec;
|
|
11
13
|
max(): Vec;
|
|
12
14
|
offset(offset: number): this;
|
|
13
15
|
toHiccup(): (string | number | Vec | Attribs | undefined)[];
|
package/api/rect.js
CHANGED
|
@@ -1,41 +1,44 @@
|
|
|
1
1
|
import { add2 } from "@thi.ng/vectors/add";
|
|
2
2
|
import { addN2 } from "@thi.ng/vectors/addn";
|
|
3
3
|
import { ZERO2 } from "@thi.ng/vectors/api";
|
|
4
|
+
import { maddN2 } from "@thi.ng/vectors/maddn";
|
|
4
5
|
import { max2 } from "@thi.ng/vectors/max";
|
|
5
6
|
import { set2 } from "@thi.ng/vectors/set";
|
|
6
|
-
import { subN2 } from "@thi.ng/vectors/subn";
|
|
7
7
|
import { __asVec } from "../internal/args.js";
|
|
8
8
|
import { __copyAttribs } from "../internal/copy.js";
|
|
9
9
|
class Rect {
|
|
10
10
|
constructor(pos = [0, 0], size = 1, attribs) {
|
|
11
11
|
this.pos = pos;
|
|
12
12
|
this.attribs = attribs;
|
|
13
|
-
this.size = __asVec(size);
|
|
13
|
+
this.size = max2(null, __asVec(size), ZERO2);
|
|
14
14
|
}
|
|
15
|
+
type = "rect";
|
|
16
|
+
dim = 2;
|
|
15
17
|
size;
|
|
16
|
-
get type() {
|
|
17
|
-
return "rect";
|
|
18
|
-
}
|
|
19
18
|
copy() {
|
|
20
19
|
return new Rect(
|
|
21
20
|
set2([], this.pos),
|
|
22
21
|
set2([], this.size),
|
|
23
|
-
__copyAttribs(this)
|
|
22
|
+
__copyAttribs(this.attribs)
|
|
24
23
|
);
|
|
25
24
|
}
|
|
26
25
|
withAttribs(attribs) {
|
|
27
26
|
return new Rect(this.pos, this.size, attribs);
|
|
28
27
|
}
|
|
28
|
+
min() {
|
|
29
|
+
return set2([], this.pos);
|
|
30
|
+
}
|
|
29
31
|
max() {
|
|
30
32
|
return add2([], this.pos, this.size);
|
|
31
33
|
}
|
|
32
34
|
offset(offset) {
|
|
33
|
-
|
|
35
|
+
const c = maddN2([], this.size, 0.5, this.pos);
|
|
34
36
|
max2(null, addN2(null, this.size, offset * 2), ZERO2);
|
|
37
|
+
maddN2(this.pos, this.size, -0.5, c);
|
|
35
38
|
return this;
|
|
36
39
|
}
|
|
37
40
|
toHiccup() {
|
|
38
|
-
return [
|
|
41
|
+
return [this.type, this.attribs, this.pos, this.size[0], this.size[1]];
|
|
39
42
|
}
|
|
40
43
|
}
|
|
41
44
|
export {
|
package/api/sphere.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 Sphere implements IHiccupShape3<Sphere> {
|
|
4
4
|
pos: Vec;
|
|
5
5
|
r: number;
|
|
6
6
|
attribs?: Attribs | undefined;
|
|
7
|
+
readonly type = "sphere";
|
|
8
|
+
readonly dim = 3;
|
|
7
9
|
constructor(pos?: Vec, r?: number, attribs?: Attribs | undefined);
|
|
8
|
-
get type(): string;
|
|
9
10
|
copy(): Sphere;
|
|
10
11
|
withAttribs(attribs: Attribs): Sphere;
|
|
11
12
|
toHiccup(): (string | number | Vec | Attribs | undefined)[];
|
package/api/sphere.js
CHANGED
|
@@ -6,17 +6,20 @@ class Sphere {
|
|
|
6
6
|
this.r = r;
|
|
7
7
|
this.attribs = attribs;
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
9
|
+
type = "sphere";
|
|
10
|
+
dim = 3;
|
|
12
11
|
copy() {
|
|
13
|
-
return new Sphere(
|
|
12
|
+
return new Sphere(
|
|
13
|
+
set3([], this.pos),
|
|
14
|
+
this.r,
|
|
15
|
+
__copyAttribs(this.attribs)
|
|
16
|
+
);
|
|
14
17
|
}
|
|
15
18
|
withAttribs(attribs) {
|
|
16
19
|
return new Sphere(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/text.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Attribs, IHiccupShape } from "@thi.ng/geom-api";
|
|
2
1
|
import type { Vec } from "@thi.ng/vectors";
|
|
2
|
+
import type { Attribs, IHiccupShape2 } from "../api.js";
|
|
3
3
|
/**
|
|
4
4
|
* Basic stub for text elements. Currently, only a minimal set of geometry
|
|
5
5
|
* operations are implemented for this type, however this type implements
|
|
@@ -7,12 +7,13 @@ import type { Vec } from "@thi.ng/vectors";
|
|
|
7
7
|
* so is useful as wrapper for inclusion of text elements in {@link Group}s with
|
|
8
8
|
* other shape types.
|
|
9
9
|
*/
|
|
10
|
-
export declare class Text implements
|
|
10
|
+
export declare class Text implements IHiccupShape2<Text> {
|
|
11
11
|
pos: Vec;
|
|
12
12
|
body: any;
|
|
13
13
|
attribs?: Attribs | undefined;
|
|
14
|
+
readonly type = "text";
|
|
15
|
+
readonly dim = 2;
|
|
14
16
|
constructor(pos: Vec, body: any, attribs?: Attribs | undefined);
|
|
15
|
-
get type(): string;
|
|
16
17
|
copy(): Text;
|
|
17
18
|
withAttribs(attribs: Attribs): Text;
|
|
18
19
|
toHiccup(): any[];
|
package/api/text.js
CHANGED
|
@@ -6,17 +6,20 @@ class Text {
|
|
|
6
6
|
this.body = body;
|
|
7
7
|
this.attribs = attribs;
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
9
|
+
type = "text";
|
|
10
|
+
dim = 2;
|
|
12
11
|
copy() {
|
|
13
|
-
return new Text(
|
|
12
|
+
return new Text(
|
|
13
|
+
set([], this.pos),
|
|
14
|
+
this.body,
|
|
15
|
+
__copyAttribs(this.attribs)
|
|
16
|
+
);
|
|
14
17
|
}
|
|
15
18
|
withAttribs(attribs) {
|
|
16
19
|
return new Text(this.pos, this.body, attribs);
|
|
17
20
|
}
|
|
18
21
|
toHiccup() {
|
|
19
|
-
return [
|
|
22
|
+
return [this.type, this.attribs, this.pos, this.body];
|
|
20
23
|
}
|
|
21
24
|
}
|
|
22
25
|
export {
|
package/api/triangle.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 Triangle extends APC implements
|
|
5
|
+
export declare class Triangle extends APC implements IHiccupShape2<Triangle> {
|
|
6
|
+
readonly type = "tri";
|
|
7
|
+
readonly dim = 2;
|
|
5
8
|
constructor(points: Iterable<Vec>, attribs?: Attribs);
|
|
6
|
-
get type(): string;
|
|
7
9
|
copy(): Triangle;
|
|
10
|
+
copyTransformed(fn: Fn<ReadonlyVec[], Vec[]>): Triangle;
|
|
8
11
|
withAttribs(attribs: Attribs): Triangle;
|
|
9
12
|
toHiccup(): (string | Vec[] | Attribs | undefined)[];
|
|
10
13
|
}
|
package/api/triangle.js
CHANGED
|
@@ -2,16 +2,18 @@ import { __copyShape } from "../internal/copy.js";
|
|
|
2
2
|
import { __ensureNumVerts } from "../internal/pclike.js";
|
|
3
3
|
import { APC } from "./apc.js";
|
|
4
4
|
class Triangle extends APC {
|
|
5
|
+
type = "tri";
|
|
6
|
+
dim = 2;
|
|
5
7
|
constructor(points, attribs) {
|
|
6
8
|
super(points, attribs);
|
|
7
9
|
__ensureNumVerts(this.points.length, 3);
|
|
8
10
|
}
|
|
9
|
-
get type() {
|
|
10
|
-
return "tri";
|
|
11
|
-
}
|
|
12
11
|
copy() {
|
|
13
12
|
return __copyShape(Triangle, this);
|
|
14
13
|
}
|
|
14
|
+
copyTransformed(fn) {
|
|
15
|
+
return __copyShape(Triangle, this, fn(this.points));
|
|
16
|
+
}
|
|
15
17
|
withAttribs(attribs) {
|
|
16
18
|
return new Triangle(this.points, attribs);
|
|
17
19
|
}
|
|
@@ -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 Triangle3 extends APC implements IHiccupShape3<Triangle3> {
|
|
6
|
+
readonly type = "tri3";
|
|
7
|
+
readonly dim = 3;
|
|
8
|
+
constructor(points: Iterable<Vec>, attribs?: Attribs);
|
|
9
|
+
copy(): Triangle3;
|
|
10
|
+
copyTransformed(fn: Fn<ReadonlyVec[], Vec[]>): Triangle3;
|
|
11
|
+
withAttribs(attribs: Attribs): Triangle3;
|
|
12
|
+
toHiccup(): (string | Vec[] | Attribs | undefined)[];
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=triangle3.d.ts.map
|
package/api/triangle3.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { __copyShape } from "../internal/copy.js";
|
|
2
|
+
import { __ensureNumVerts } from "../internal/pclike.js";
|
|
3
|
+
import { APC } from "./apc.js";
|
|
4
|
+
class Triangle3 extends APC {
|
|
5
|
+
type = "tri3";
|
|
6
|
+
dim = 3;
|
|
7
|
+
constructor(points, attribs) {
|
|
8
|
+
super(points, attribs);
|
|
9
|
+
__ensureNumVerts(this.points.length, 3);
|
|
10
|
+
}
|
|
11
|
+
copy() {
|
|
12
|
+
return __copyShape(Triangle3, this);
|
|
13
|
+
}
|
|
14
|
+
copyTransformed(fn) {
|
|
15
|
+
return __copyShape(Triangle3, this, fn(this.points));
|
|
16
|
+
}
|
|
17
|
+
withAttribs(attribs) {
|
|
18
|
+
return new Triangle3(this.points, attribs);
|
|
19
|
+
}
|
|
20
|
+
toHiccup() {
|
|
21
|
+
return ["polygon3", this.attribs, this.points];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
Triangle3
|
|
26
|
+
};
|