curvy 1.0.7 → 1.0.9
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/dist/curve/cubic2d.d.mts +80 -2
- package/dist/curve/cubic2d.d.ts +80 -2
- package/dist/curve/cubic2d.mjs +9 -26
- package/dist/curve/cubic2d.mjs.map +1 -0
- package/dist/curve/linear2d.d.mts +68 -2
- package/dist/curve/linear2d.d.ts +68 -2
- package/dist/curve/linear2d.mjs +11 -14
- package/dist/curve/linear2d.mjs.map +1 -0
- package/dist/curve/quadratic2d.d.mts +86 -2
- package/dist/curve/quadratic2d.d.ts +86 -2
- package/dist/curve/quadratic2d.mjs +10 -15
- package/dist/curve/quadratic2d.mjs.map +1 -0
- package/dist/interval.d.mts +195 -2
- package/dist/interval.d.ts +195 -2
- package/dist/interval.mjs +9 -12
- package/dist/interval.mjs.map +1 -0
- package/dist/matrix/matrix2x2.d.mts +273 -2
- package/dist/matrix/matrix2x2.d.ts +273 -2
- package/dist/matrix/matrix2x2.mjs +5 -4
- package/dist/matrix/matrix2x2.mjs.map +1 -0
- package/dist/matrix/matrix3x3.d.mts +308 -1
- package/dist/matrix/matrix3x3.d.ts +308 -1
- package/dist/matrix/matrix3x3.mjs +5 -4
- package/dist/matrix/matrix3x3.mjs.map +1 -0
- package/dist/matrix/matrix4x4.d.mts +310 -1
- package/dist/matrix/matrix4x4.d.ts +310 -1
- package/dist/matrix/matrix4x4.mjs +24 -61
- package/dist/matrix/matrix4x4.mjs.map +1 -0
- package/dist/path/cubic2d.d.mts +68 -2
- package/dist/path/cubic2d.d.ts +68 -2
- package/dist/path/cubic2d.mjs +10 -12
- package/dist/path/cubic2d.mjs.map +1 -0
- package/dist/path/linear2d.d.mts +68 -2
- package/dist/path/linear2d.d.ts +68 -2
- package/dist/path/linear2d.mjs +7 -9
- package/dist/path/linear2d.mjs.map +1 -0
- package/dist/path/quadratic2d.d.mts +67 -2
- package/dist/path/quadratic2d.d.ts +67 -2
- package/dist/path/quadratic2d.mjs +9 -13
- package/dist/path/quadratic2d.mjs.map +1 -0
- package/dist/pipe.mjs +1 -0
- package/dist/pipe.mjs.map +1 -0
- package/dist/polynomial/cubic.d.mts +1 -1
- package/dist/polynomial/cubic.d.ts +1 -1
- package/dist/polynomial/cubic.mjs +13 -28
- package/dist/polynomial/cubic.mjs.map +1 -0
- package/dist/polynomial/linear.d.mts +1 -1
- package/dist/polynomial/linear.d.ts +1 -1
- package/dist/polynomial/linear.mjs +2 -1
- package/dist/polynomial/linear.mjs.map +1 -0
- package/dist/polynomial/quadratic.d.mts +2 -2
- package/dist/polynomial/quadratic.d.ts +2 -2
- package/dist/polynomial/quadratic.mjs +5 -2
- package/dist/polynomial/quadratic.mjs.map +1 -0
- package/dist/shared/{curvy.Cps2R_RU.mjs → curvy.BkkW8Tx9.mjs} +11 -29
- package/dist/shared/curvy.BkkW8Tx9.mjs.map +1 -0
- package/dist/shared/{curvy.BzVmUIKm.mjs → curvy.BxdGW9he.mjs} +17 -32
- package/dist/shared/curvy.BxdGW9he.mjs.map +1 -0
- package/dist/shared/{curvy.C2XGH0R0.mjs → curvy.C_sCeg9J.mjs} +15 -24
- package/dist/shared/curvy.C_sCeg9J.mjs.map +1 -0
- package/dist/shared/curvy.Cg8lZVUz.d.ts +688 -0
- package/dist/shared/{curvy.CE4X6_Is.mjs → curvy.DCt1gGII.mjs} +11 -45
- package/dist/shared/curvy.DCt1gGII.mjs.map +1 -0
- package/dist/shared/{curvy.BZ_mTkJe.mjs → curvy.DJ4xO0al.mjs} +9 -6
- package/dist/shared/curvy.DJ4xO0al.mjs.map +1 -0
- package/dist/shared/curvy.DmVFTi0N.mjs +1 -0
- package/dist/shared/curvy.DmVFTi0N.mjs.map +1 -0
- package/dist/shared/curvy.FDaj5rlj.d.mts +688 -0
- package/dist/shared/{curvy.NLeFCr-9.mjs → curvy.lktriTpx.mjs} +19 -42
- package/dist/shared/curvy.lktriTpx.mjs.map +1 -0
- package/dist/shared/{curvy.Ck0of1PI.mjs → curvy.mLFprrGm.mjs} +26 -22
- package/dist/shared/curvy.mLFprrGm.mjs.map +1 -0
- package/dist/shared/{curvy.BDhiZ7He.mjs → curvy.r6f1j287.mjs} +8 -12
- package/dist/shared/curvy.r6f1j287.mjs.map +1 -0
- package/dist/splines/basis2d.d.mts +94 -2
- package/dist/splines/basis2d.d.ts +94 -2
- package/dist/splines/basis2d.mjs +13 -12
- package/dist/splines/basis2d.mjs.map +1 -0
- package/dist/splines/bezier2d.d.mts +136 -2
- package/dist/splines/bezier2d.d.ts +136 -2
- package/dist/splines/bezier2d.mjs +10 -9
- package/dist/splines/bezier2d.mjs.map +1 -0
- package/dist/splines/cardinal2d.d.mts +131 -2
- package/dist/splines/cardinal2d.d.ts +131 -2
- package/dist/splines/cardinal2d.mjs +15 -24
- package/dist/splines/cardinal2d.mjs.map +1 -0
- package/dist/splines/hermite2d.d.mts +94 -3
- package/dist/splines/hermite2d.d.ts +94 -3
- package/dist/splines/hermite2d.mjs +22 -36
- package/dist/splines/hermite2d.mjs.map +1 -0
- package/dist/utils.d.mts +179 -1
- package/dist/utils.d.ts +179 -1
- package/dist/utils.mjs +16 -7
- package/dist/utils.mjs.map +1 -0
- package/dist/vector/vector2.d.mts +259 -1
- package/dist/vector/vector2.d.ts +259 -1
- package/dist/vector/vector2.mjs +4 -2
- package/dist/vector/vector2.mjs.map +1 -0
- package/dist/vector/vector3.d.mts +345 -1
- package/dist/vector/vector3.d.ts +345 -1
- package/dist/vector/vector3.mjs +9 -2
- package/dist/vector/vector3.mjs.map +1 -0
- package/dist/vector/vector4.d.mts +163 -1
- package/dist/vector/vector4.d.ts +163 -1
- package/dist/vector/vector4.mjs +4 -2
- package/dist/vector/vector4.mjs.map +1 -0
- package/package.json +4 -4
- package/dist/shared/curvy.BsHoYJNv.d.ts +0 -155
- package/dist/shared/curvy.NsmY7zcr.d.mts +0 -155
|
@@ -10,40 +10,169 @@ import '../vector/vector3.js';
|
|
|
10
10
|
import '../matrix/matrix2x2.js';
|
|
11
11
|
import '../curve/cubic2d.js';
|
|
12
12
|
import '../interval.js';
|
|
13
|
-
import '../shared/curvy.
|
|
13
|
+
import '../shared/curvy.Cg8lZVUz.js';
|
|
14
14
|
|
|
15
15
|
declare const Cardinal2dTypeId: unique symbol;
|
|
16
16
|
type Cardinal2dTypeId = typeof Cardinal2dTypeId;
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* A Cardinal spline in 2D space.
|
|
20
|
+
*
|
|
21
|
+
* All fields are readonly and immutable, and all operations create new instances.
|
|
22
|
+
*
|
|
23
|
+
* @since 1.0.0
|
|
24
|
+
*/
|
|
18
25
|
interface Cardinal2d extends Pipeable {
|
|
19
26
|
readonly [Cardinal2dTypeId]: Cardinal2dTypeId;
|
|
20
27
|
[Symbol.iterator](): IterableIterator<Vector2>;
|
|
21
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* The characteristic matrix of a Cardinal spline.
|
|
31
|
+
*
|
|
32
|
+
* The characteristic matrix is a 4x4 matrix that defines the shape of the spline.
|
|
33
|
+
*
|
|
34
|
+
* @param scale - The tension of the spline.
|
|
35
|
+
* @returns The characteristic matrix.
|
|
36
|
+
* @since 1.0.0
|
|
37
|
+
*/
|
|
22
38
|
declare const characteristic: (scale: number) => Matrix4x4;
|
|
39
|
+
/**
|
|
40
|
+
* The characteristic matrix of a Catmull-Rom spline.
|
|
41
|
+
*
|
|
42
|
+
* The characteristic matrix is a 4x4 matrix that defines the shape of the spline.
|
|
43
|
+
*
|
|
44
|
+
* @since 1.0.0
|
|
45
|
+
*/
|
|
23
46
|
declare const catRomCharacteristic: Matrix4x4;
|
|
47
|
+
/**
|
|
48
|
+
* Checks if a value is a `Cardinal2d`.
|
|
49
|
+
*
|
|
50
|
+
* @param p - The value to check.
|
|
51
|
+
* @returns `true` if the value is a `Cardinal2d`, `false` otherwise.
|
|
52
|
+
* @since 1.0.0
|
|
53
|
+
*/
|
|
24
54
|
declare const isCardinal2d: (p: unknown) => p is Cardinal2d;
|
|
55
|
+
/**
|
|
56
|
+
* Creates a new `Cardinal2d` instance.
|
|
57
|
+
*
|
|
58
|
+
* @param p0 - The first control point.
|
|
59
|
+
* @param p1 - The second control point.
|
|
60
|
+
* @param points - The remaining control points.
|
|
61
|
+
* @returns A new `Cardinal2d` instance.
|
|
62
|
+
* @since 1.0.0
|
|
63
|
+
*/
|
|
25
64
|
declare const make: (p0: Vector2, p1: Vector2, ...points: ReadonlyArray<Vector2>) => Cardinal2d;
|
|
65
|
+
/**
|
|
66
|
+
* Creates a new `Cardinal2d` instance from an array of control points.
|
|
67
|
+
*
|
|
68
|
+
* @param points - The control points.
|
|
69
|
+
* @returns A new `Cardinal2d` instance.
|
|
70
|
+
* @since 1.0.0
|
|
71
|
+
*/
|
|
26
72
|
declare const fromArray: (points: ReadonlyArray<Vector2>) => Cardinal2d;
|
|
27
73
|
declare const append: {
|
|
74
|
+
/**
|
|
75
|
+
* Appends control points to a `Cardinal2d`.
|
|
76
|
+
*
|
|
77
|
+
* @param points - The control points to append.
|
|
78
|
+
* @returns A function that takes a `Cardinal2d` and returns a new `Cardinal2d` instance with the appended control points.
|
|
79
|
+
* @since 1.0.0
|
|
80
|
+
*/
|
|
28
81
|
(...points: ReadonlyArray<Vector2>): (c: Cardinal2d) => Cardinal2d;
|
|
82
|
+
/**
|
|
83
|
+
* Appends control points to a `Cardinal2d`.
|
|
84
|
+
*
|
|
85
|
+
* @param c - The `Cardinal2d` to append the control points to.
|
|
86
|
+
* @param points - The control points to append.
|
|
87
|
+
* @returns A new `Cardinal2d` instance with the appended control points.
|
|
88
|
+
* @since 1.0.0
|
|
89
|
+
*/
|
|
29
90
|
(c: Cardinal2d, ...points: ReadonlyArray<Vector2>): Cardinal2d;
|
|
30
91
|
};
|
|
31
92
|
declare const prepend: {
|
|
93
|
+
/**
|
|
94
|
+
* Prepends control points to a `Cardinal2d`.
|
|
95
|
+
*
|
|
96
|
+
* @param points - The control points to prepend.
|
|
97
|
+
* @returns A function that takes a `Cardinal2d` and returns a new `Cardinal2d` instance with the prepended control points.
|
|
98
|
+
* @since 1.0.0
|
|
99
|
+
*/
|
|
32
100
|
(...points: ReadonlyArray<Vector2>): (c: Cardinal2d) => Cardinal2d;
|
|
101
|
+
/**
|
|
102
|
+
* Prepends control points to a `Cardinal2d`.
|
|
103
|
+
*
|
|
104
|
+
* @param c - The `Cardinal2d` to prepend the control points to.
|
|
105
|
+
* @param points - The control points to prepend.
|
|
106
|
+
* @returns A new `Cardinal2d` instance with the prepended control points.
|
|
107
|
+
* @since 1.0.0
|
|
108
|
+
*/
|
|
33
109
|
(c: Cardinal2d, ...points: ReadonlyArray<Vector2>): Cardinal2d;
|
|
34
110
|
};
|
|
111
|
+
/**
|
|
112
|
+
* Doubles the endpoints of a `Cardinal2d` spline.
|
|
113
|
+
*
|
|
114
|
+
* @param c - The `Cardinal2d` to duplicate the endpoints of.
|
|
115
|
+
* @returns A new `Cardinal2d` instance with the duplicated endpoints.
|
|
116
|
+
* @since 1.0.0
|
|
117
|
+
*/
|
|
35
118
|
declare const withDuplicatedEndpoints: (c: Cardinal2d) => Cardinal2d;
|
|
36
119
|
declare const withReflectedEndpoints: {
|
|
120
|
+
/**
|
|
121
|
+
* Reflects the endpoints of a `Cardinal2d` spline.
|
|
122
|
+
*
|
|
123
|
+
* @param scale - The scale factor for the reflection.
|
|
124
|
+
* @returns A function that takes a `Cardinal2d` and returns a new `Cardinal2d` instance with the reflected endpoints.
|
|
125
|
+
* @since 1.0.0
|
|
126
|
+
*/
|
|
37
127
|
(scale: number): (c: Cardinal2d) => Cardinal2d;
|
|
128
|
+
/**
|
|
129
|
+
* Reflects the endpoints of a `Cardinal2d` spline.
|
|
130
|
+
*
|
|
131
|
+
* @param c - The `Cardinal2d` to reflect the endpoints of.
|
|
132
|
+
* @param scale - The scale factor for the reflection.
|
|
133
|
+
* @returns A new `Cardinal2d` instance with the reflected endpoints.
|
|
134
|
+
* @since 1.0.0
|
|
135
|
+
*/
|
|
38
136
|
(c: Cardinal2d, scale?: number): Cardinal2d;
|
|
39
137
|
};
|
|
40
138
|
declare const toPath: {
|
|
139
|
+
/**
|
|
140
|
+
* Converts a `Cardinal2d` to a `CubicPath2d`.
|
|
141
|
+
*
|
|
142
|
+
* @param scale - The scale factor for the conversion.
|
|
143
|
+
* @returns A Function that takes a `Cardinal2d` and returns a new `CubicPath2d` instance.
|
|
144
|
+
* @since 1.0.0
|
|
145
|
+
*/
|
|
41
146
|
(scale: number): (c: Cardinal2d) => CubicPath2d;
|
|
147
|
+
/**
|
|
148
|
+
* Converts a `Cardinal2d` to a `CubicPath2d`.
|
|
149
|
+
*
|
|
150
|
+
* @param c - The `Cardinal2d` to convert.
|
|
151
|
+
* @param scale - The scale factor for the conversion.
|
|
152
|
+
* @returns A new `CubicPath2d` instance representing the same curve as the `Cardinal2d`.
|
|
153
|
+
* @since 1.0.0
|
|
154
|
+
*/
|
|
42
155
|
(c: Cardinal2d, scale?: number): CubicPath2d;
|
|
43
156
|
};
|
|
44
157
|
declare const toBezier: {
|
|
158
|
+
/**
|
|
159
|
+
* Converts a `Cardinal2d` to a `Bezier2d`.
|
|
160
|
+
*
|
|
161
|
+
* @param p - The `Cardinal2d` to convert.
|
|
162
|
+
* @returns A new `Bezier2d` instance representing the same curve as the `Cardinal2d`.
|
|
163
|
+
* @since 1.0.0
|
|
164
|
+
*/
|
|
45
165
|
(p: Cardinal2d): Bezier2d;
|
|
166
|
+
/**
|
|
167
|
+
* Converts a `Cardinal2d` to a `Bezier2d`.
|
|
168
|
+
*
|
|
169
|
+
* @param p - The `Cardinal2d` to convert.
|
|
170
|
+
* @param scale - The scale factor for the conversion.
|
|
171
|
+
* @returns A new `Bezier2d` instance representing the same curve as the `Cardinal2d`.
|
|
172
|
+
* @since 1.0.0
|
|
173
|
+
*/
|
|
46
174
|
(p: Cardinal2d, scale: number): Bezier2d;
|
|
47
175
|
};
|
|
48
176
|
|
|
49
|
-
export {
|
|
177
|
+
export { append, catRomCharacteristic, characteristic, fromArray, isCardinal2d, make, prepend, toBezier, toPath, withDuplicatedEndpoints, withReflectedEndpoints };
|
|
178
|
+
export type { Cardinal2d };
|
|
@@ -3,24 +3,25 @@ import { fromCurves } from '../path/cubic2d.mjs';
|
|
|
3
3
|
import { dual, Pipeable } from '../pipe.mjs';
|
|
4
4
|
import { invariant } from '../utils.mjs';
|
|
5
5
|
import { subtract, scale, add } from '../vector/vector2.mjs';
|
|
6
|
-
import {
|
|
7
|
-
import '../shared/curvy.
|
|
8
|
-
import '../shared/curvy.
|
|
9
|
-
import '../shared/curvy.
|
|
10
|
-
import '../shared/curvy.
|
|
11
|
-
import '../shared/curvy.
|
|
6
|
+
import { f as fromSpline, t as toCurves } from '../shared/curvy.DCt1gGII.mjs';
|
|
7
|
+
import '../shared/curvy.BkkW8Tx9.mjs';
|
|
8
|
+
import '../shared/curvy.DJ4xO0al.mjs';
|
|
9
|
+
import '../shared/curvy.C_sCeg9J.mjs';
|
|
10
|
+
import '../shared/curvy.lktriTpx.mjs';
|
|
11
|
+
import '../shared/curvy.mLFprrGm.mjs';
|
|
12
12
|
import '../curve/cubic2d.mjs';
|
|
13
13
|
import '../interval.mjs';
|
|
14
14
|
import '../shared/curvy.DmVFTi0N.mjs';
|
|
15
15
|
import '../polynomial/cubic.mjs';
|
|
16
|
-
import '../shared/curvy.
|
|
17
|
-
import '../shared/curvy.
|
|
16
|
+
import '../shared/curvy.BxdGW9he.mjs';
|
|
17
|
+
import '../shared/curvy.r6f1j287.mjs';
|
|
18
18
|
import '../polynomial/quadratic.mjs';
|
|
19
19
|
import '../curve/linear2d.mjs';
|
|
20
20
|
import '../polynomial/linear.mjs';
|
|
21
21
|
import '../curve/quadratic2d.mjs';
|
|
22
22
|
import '../vector/vector4.mjs';
|
|
23
23
|
|
|
24
|
+
var _a;
|
|
24
25
|
const characteristic$1 = (scale) => make$2(
|
|
25
26
|
0,
|
|
26
27
|
1,
|
|
@@ -40,18 +41,15 @@ const characteristic$1 = (scale) => make$2(
|
|
|
40
41
|
scale
|
|
41
42
|
);
|
|
42
43
|
const catRomCharacteristic$1 = characteristic$1(0.5);
|
|
43
|
-
const Cardinal2dTypeId = Symbol.for(
|
|
44
|
-
"curvy/splines/cardinal2d"
|
|
45
|
-
);
|
|
44
|
+
const Cardinal2dTypeId = Symbol.for("curvy/splines/cardinal2d");
|
|
46
45
|
class Cardinal2dImpl extends Pipeable {
|
|
47
|
-
[Cardinal2dTypeId] = Cardinal2dTypeId;
|
|
48
|
-
points;
|
|
49
46
|
constructor(points) {
|
|
50
47
|
invariant(points.length >= 2, "cardinal splines requires 2 or more points");
|
|
51
48
|
super();
|
|
49
|
+
this[_a] = Cardinal2dTypeId;
|
|
52
50
|
this.points = points;
|
|
53
51
|
}
|
|
54
|
-
[Symbol.iterator]() {
|
|
52
|
+
[(_a = Cardinal2dTypeId, Symbol.iterator)]() {
|
|
55
53
|
return this.points[Symbol.iterator]();
|
|
56
54
|
}
|
|
57
55
|
}
|
|
@@ -95,18 +93,10 @@ const withReflectedEndpoints$1 = dual(
|
|
|
95
93
|
const toPath$1 = dual(
|
|
96
94
|
(args) => isCardinal2d$1(args[0]),
|
|
97
95
|
(p, scale = 0.5) => fromCurves(
|
|
98
|
-
...toCurves(
|
|
99
|
-
p,
|
|
100
|
-
scale === 0.5 ? catRomCharacteristic$1 : characteristic$1(scale),
|
|
101
|
-
1
|
|
102
|
-
)
|
|
96
|
+
...toCurves(p, scale === 0.5 ? catRomCharacteristic$1 : characteristic$1(scale), 1)
|
|
103
97
|
)
|
|
104
98
|
);
|
|
105
|
-
const toBezier$1 = (p, scale = 0.5) => fromSpline(
|
|
106
|
-
p,
|
|
107
|
-
scale === 0.5 ? catRomCharacteristic$1 : characteristic$1(scale),
|
|
108
|
-
1
|
|
109
|
-
);
|
|
99
|
+
const toBezier$1 = (p, scale = 0.5) => fromSpline(p, scale === 0.5 ? catRomCharacteristic$1 : characteristic$1(scale), 1);
|
|
110
100
|
|
|
111
101
|
const characteristic = characteristic$1;
|
|
112
102
|
const catRomCharacteristic = catRomCharacteristic$1;
|
|
@@ -121,3 +111,4 @@ const toPath = toPath$1;
|
|
|
121
111
|
const toBezier = toBezier$1;
|
|
122
112
|
|
|
123
113
|
export { append, catRomCharacteristic, characteristic, fromArray, isCardinal2d, make, prepend, toBezier, toPath, withDuplicatedEndpoints, withReflectedEndpoints };
|
|
114
|
+
//# sourceMappingURL=cardinal2d.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cardinal2d.mjs","sources":["../../src/splines/cardinal2d.internal.ts","../../src/splines/cardinal2d.ts"],"sourcesContent":["import * as Matrix4x4 from '../matrix/matrix4x4'\nimport * as CubicPath2d from '../path/cubic2d'\nimport { Pipeable } from '../pipe'\nimport { dual } from '../pipe'\nimport { invariant } from '../utils'\nimport * as Vector2 from '../vector/vector2'\nimport * as Bezier2d from './bezier2d'\nimport type { Cardinal2d } from './cardinal2d'\nimport { toCurves } from './util'\n\nexport const characteristic = (scale: number) =>\n Matrix4x4.make(\n 0,\n 1,\n 0,\n 0,\n -scale,\n 0,\n scale,\n 0,\n 2 * scale,\n scale - 3,\n 3 - 2 * scale,\n -scale,\n -scale,\n 2 - scale,\n scale - 2,\n scale,\n )\n\nexport const catRomCharacteristic = characteristic(0.5)\n\nexport const Cardinal2dTypeId: unique symbol = Symbol.for('curvy/splines/cardinal2d')\nexport type Cardinal2dTypeId = typeof Cardinal2dTypeId\n\nexport class Cardinal2dImpl extends Pipeable {\n readonly [Cardinal2dTypeId]: Cardinal2dTypeId = Cardinal2dTypeId\n\n readonly points: ReadonlyArray<Vector2.Vector2>\n\n constructor(points: ReadonlyArray<Vector2.Vector2>) {\n invariant(points.length >= 2, 'cardinal splines requires 2 or more points')\n super()\n this.points = points\n }\n\n [Symbol.iterator]() {\n return this.points[Symbol.iterator]()\n }\n}\n\nexport const isCardinal2d = (p: unknown): p is Cardinal2d =>\n typeof p === 'object' && p !== null && Cardinal2dTypeId in p\n\nexport const make = (...points: ReadonlyArray<Vector2.Vector2>) => new Cardinal2dImpl(points)\n\nexport const fromArray = (points: ReadonlyArray<Vector2.Vector2>) => new Cardinal2dImpl(points)\n\nexport const append = dual<\n (...points: ReadonlyArray<Vector2.Vector2>) => (p: Cardinal2d) => Cardinal2d,\n (p: Cardinal2d, ...points: ReadonlyArray<Vector2.Vector2>) => Cardinal2d\n>(\n (args) => isCardinal2d(args[0]),\n (p: Cardinal2d, ...points: ReadonlyArray<Vector2.Vector2>) =>\n new Cardinal2dImpl([...p, ...points]),\n)\n\nexport const prepend = dual<\n (...points: ReadonlyArray<Vector2.Vector2>) => (p: Cardinal2d) => Cardinal2d,\n (p: Cardinal2d, ...points: ReadonlyArray<Vector2.Vector2>) => Cardinal2d\n>(\n (args) => isCardinal2d(args[0]),\n (p: Cardinal2d, ...points: ReadonlyArray<Vector2.Vector2>) =>\n new Cardinal2dImpl([...points, ...p]),\n)\n\nexport const withDuplicatedEndpoints = (p: Cardinal2d) => {\n const points = p instanceof Cardinal2dImpl ? p.points : [...p]\n return new Cardinal2dImpl([\n points[0] as Vector2.Vector2,\n ...points,\n points[points.length - 1] as Vector2.Vector2,\n ])\n}\n\nexport const withReflectedEndpoints = dual(\n (args) => isCardinal2d(args[0]),\n (p: Cardinal2d, scale = 1) => {\n if (scale === 0) {\n return withDuplicatedEndpoints(p)\n }\n\n const points = p instanceof Cardinal2dImpl ? p.points : [...p]\n const p0 = points[0] as Vector2.Vector2\n const p1 = points[1] as Vector2.Vector2\n\n const p2 = points[points.length - 2] as Vector2.Vector2\n const p3 = points[points.length - 1] as Vector2.Vector2\n\n return new Cardinal2dImpl([\n Vector2.subtract(p1, p0).pipe(Vector2.scale(scale), Vector2.add(p0)),\n ...points,\n Vector2.subtract(p2, p3).pipe(Vector2.scale(scale), Vector2.add(p3)),\n ])\n },\n)\n\nexport const toPath = dual(\n (args) => isCardinal2d(args[0]),\n (p: Cardinal2d, scale = 0.5) =>\n CubicPath2d.fromCurves(\n ...toCurves(p, scale === 0.5 ? catRomCharacteristic : characteristic(scale), 1),\n ),\n)\n\nexport const toBezier = (p: Cardinal2d, scale = 0.5) =>\n Bezier2d.fromSpline(p, scale === 0.5 ? catRomCharacteristic : characteristic(scale), 1)\n","import type { Matrix4x4 } from '../matrix/matrix4x4'\nimport type { CubicPath2d } from '../path/cubic2d'\nimport type { Pipeable } from '../pipe'\nimport type { Vector2 } from '../vector/vector2'\nimport type { Bezier2d } from './bezier2d'\nimport type { Cardinal2dTypeId } from './cardinal2d.internal'\nimport * as internal from './cardinal2d.internal'\n\n/**\n * A Cardinal spline in 2D space.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * @since 1.0.0\n */\nexport interface Cardinal2d extends Pipeable {\n readonly [Cardinal2dTypeId]: Cardinal2dTypeId\n [Symbol.iterator](): IterableIterator<Vector2>\n}\n\n/**\n * The characteristic matrix of a Cardinal spline.\n *\n * The characteristic matrix is a 4x4 matrix that defines the shape of the spline.\n *\n * @param scale - The tension of the spline.\n * @returns The characteristic matrix.\n * @since 1.0.0\n */\nexport const characteristic: (scale: number) => Matrix4x4 = internal.characteristic\n\n/**\n * The characteristic matrix of a Catmull-Rom spline.\n *\n * The characteristic matrix is a 4x4 matrix that defines the shape of the spline.\n *\n * @since 1.0.0\n */\nexport const catRomCharacteristic: Matrix4x4 = internal.catRomCharacteristic\n\n/**\n * Checks if a value is a `Cardinal2d`.\n *\n * @param p - The value to check.\n * @returns `true` if the value is a `Cardinal2d`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isCardinal2d: (p: unknown) => p is Cardinal2d = internal.isCardinal2d\n\n/**\n * Creates a new `Cardinal2d` instance.\n *\n * @param p0 - The first control point.\n * @param p1 - The second control point.\n * @param points - The remaining control points.\n * @returns A new `Cardinal2d` instance.\n * @since 1.0.0\n */\nexport const make: (p0: Vector2, p1: Vector2, ...points: ReadonlyArray<Vector2>) => Cardinal2d =\n internal.make\n\n/**\n * Creates a new `Cardinal2d` instance from an array of control points.\n *\n * @param points - The control points.\n * @returns A new `Cardinal2d` instance.\n * @since 1.0.0\n */\nexport const fromArray: (points: ReadonlyArray<Vector2>) => Cardinal2d = internal.fromArray\n\nexport const append: {\n /**\n * Appends control points to a `Cardinal2d`.\n *\n * @param points - The control points to append.\n * @returns A function that takes a `Cardinal2d` and returns a new `Cardinal2d` instance with the appended control points.\n * @since 1.0.0\n */\n (...points: ReadonlyArray<Vector2>): (c: Cardinal2d) => Cardinal2d\n /**\n * Appends control points to a `Cardinal2d`.\n *\n * @param c - The `Cardinal2d` to append the control points to.\n * @param points - The control points to append.\n * @returns A new `Cardinal2d` instance with the appended control points.\n * @since 1.0.0\n */\n (c: Cardinal2d, ...points: ReadonlyArray<Vector2>): Cardinal2d\n} = internal.append\n\nexport const prepend: {\n /**\n * Prepends control points to a `Cardinal2d`.\n *\n * @param points - The control points to prepend.\n * @returns A function that takes a `Cardinal2d` and returns a new `Cardinal2d` instance with the prepended control points.\n * @since 1.0.0\n */\n (...points: ReadonlyArray<Vector2>): (c: Cardinal2d) => Cardinal2d\n /**\n * Prepends control points to a `Cardinal2d`.\n *\n * @param c - The `Cardinal2d` to prepend the control points to.\n * @param points - The control points to prepend.\n * @returns A new `Cardinal2d` instance with the prepended control points.\n * @since 1.0.0\n */\n (c: Cardinal2d, ...points: ReadonlyArray<Vector2>): Cardinal2d\n} = internal.prepend\n\n/**\n * Doubles the endpoints of a `Cardinal2d` spline.\n *\n * @param c - The `Cardinal2d` to duplicate the endpoints of.\n * @returns A new `Cardinal2d` instance with the duplicated endpoints.\n * @since 1.0.0\n */\nexport const withDuplicatedEndpoints: (c: Cardinal2d) => Cardinal2d =\n internal.withDuplicatedEndpoints\n\nexport const withReflectedEndpoints: {\n /**\n * Reflects the endpoints of a `Cardinal2d` spline.\n *\n * @param scale - The scale factor for the reflection.\n * @returns A function that takes a `Cardinal2d` and returns a new `Cardinal2d` instance with the reflected endpoints.\n * @since 1.0.0\n */\n (scale: number): (c: Cardinal2d) => Cardinal2d\n /**\n * Reflects the endpoints of a `Cardinal2d` spline.\n *\n * @param c - The `Cardinal2d` to reflect the endpoints of.\n * @param scale - The scale factor for the reflection.\n * @returns A new `Cardinal2d` instance with the reflected endpoints.\n * @since 1.0.0\n */\n (c: Cardinal2d, scale?: number): Cardinal2d\n} = internal.withReflectedEndpoints\n\nexport const toPath: {\n /**\n * Converts a `Cardinal2d` to a `CubicPath2d`.\n *\n * @param scale - The scale factor for the conversion.\n * @returns A Function that takes a `Cardinal2d` and returns a new `CubicPath2d` instance.\n * @since 1.0.0\n */\n (scale: number): (c: Cardinal2d) => CubicPath2d\n /**\n * Converts a `Cardinal2d` to a `CubicPath2d`.\n *\n * @param c - The `Cardinal2d` to convert.\n * @param scale - The scale factor for the conversion.\n * @returns A new `CubicPath2d` instance representing the same curve as the `Cardinal2d`.\n * @since 1.0.0\n */\n (c: Cardinal2d, scale?: number): CubicPath2d\n} = internal.toPath\n\nexport const toBezier: {\n /**\n * Converts a `Cardinal2d` to a `Bezier2d`.\n *\n * @param p - The `Cardinal2d` to convert.\n * @returns A new `Bezier2d` instance representing the same curve as the `Cardinal2d`.\n * @since 1.0.0\n */\n (p: Cardinal2d): Bezier2d\n /**\n * Converts a `Cardinal2d` to a `Bezier2d`.\n *\n * @param p - The `Cardinal2d` to convert.\n * @param scale - The scale factor for the conversion.\n * @returns A new `Bezier2d` instance representing the same curve as the `Cardinal2d`.\n * @since 1.0.0\n */\n (p: Cardinal2d, scale: number): Bezier2d\n} = internal.toBezier\n"],"names":["characteristic","Matrix4x4.make","catRomCharacteristic","isCardinal2d","make","fromArray","append","prepend","withDuplicatedEndpoints","withReflectedEndpoints","scale","Vector2.subtract","Vector2.scale","Vector2.add","toPath","CubicPath2d.fromCurves","toBezier","Bezier2d.fromSpline","internal.characteristic","internal.catRomCharacteristic","internal.isCardinal2d","internal.make","internal.fromArray","internal.append","internal.prepend","internal.withDuplicatedEndpoints","internal.withReflectedEndpoints","internal.toPath","internal.toBezier"],"mappings":";;;;;;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ector/vector3.mjs';
|
|
|
10
10
|
import '../matrix/matrix2x2.mjs';
|
|
11
11
|
import '../curve/cubic2d.mjs';
|
|
12
12
|
import '../interval.mjs';
|
|
13
|
-
import '../shared/curvy.
|
|
13
|
+
import '../shared/curvy.FDaj5rlj.mjs';
|
|
14
14
|
|
|
15
15
|
declare const Hermite2dTypeId: unique symbol;
|
|
16
16
|
type Hermite2dTypeId = typeof Hermite2dTypeId;
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* A Hermite spline in 2D space.
|
|
20
|
+
*
|
|
21
|
+
* All fields are readonly and immutable, and all operations create new instances.
|
|
22
|
+
*
|
|
23
|
+
* @since 1.0.0
|
|
24
|
+
*/
|
|
18
25
|
interface Hermite2d extends Pipeable {
|
|
19
26
|
readonly [Hermite2dTypeId]: Hermite2dTypeId;
|
|
20
27
|
[Symbol.iterator](): IterableIterator<Vector2>;
|
|
21
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* The characteristic matrix of a Hermite spline.
|
|
31
|
+
*
|
|
32
|
+
* The characteristic matrix is a 4x4 matrix that defines the shape of the spline.
|
|
33
|
+
*
|
|
34
|
+
* @since 1.0.0
|
|
35
|
+
*/
|
|
22
36
|
declare const characteristic: Matrix4x4;
|
|
37
|
+
/**
|
|
38
|
+
* Checks if a value is a `Hermite2d`.
|
|
39
|
+
*
|
|
40
|
+
* @param p - The value to check.
|
|
41
|
+
* @returns `true` if the value is a `Hermite2d`, `false` otherwise.
|
|
42
|
+
* @since 1.0.0
|
|
43
|
+
*/
|
|
44
|
+
declare const isHermite2d: (p: unknown) => p is Hermite2d;
|
|
45
|
+
/**
|
|
46
|
+
* Creates a new `Hermite2d` instance.
|
|
47
|
+
*
|
|
48
|
+
* @param p0 - The first control point.
|
|
49
|
+
* @param v0 - The first tangent vector.
|
|
50
|
+
* @param p1 - The second control point.
|
|
51
|
+
* @param v1 - The second tangent vector.
|
|
52
|
+
* @returns A new `Hermite2d` instance.
|
|
53
|
+
* @since 1.0.0
|
|
54
|
+
*/
|
|
23
55
|
declare const make: (p0: Vector2, v0: Vector2, p1: Vector2, v1: Vector2) => Hermite2d;
|
|
56
|
+
/**
|
|
57
|
+
* Creates a new `Hermite2d` instance from an array of control points.
|
|
58
|
+
*
|
|
59
|
+
* @param points - The control points.
|
|
60
|
+
* @returns A new `Hermite2d` instance.
|
|
61
|
+
* @since 1.0.0
|
|
62
|
+
*/
|
|
24
63
|
declare const fromArray: (points: ReadonlyArray<Vector2>) => Hermite2d;
|
|
25
|
-
declare const isHermite2d: (p: unknown) => p is Hermite2d;
|
|
26
64
|
declare const append: {
|
|
65
|
+
/**
|
|
66
|
+
* Appends a new control point and tangent vector to the Hermite spline.
|
|
67
|
+
*
|
|
68
|
+
* @param p1 - The new control point.
|
|
69
|
+
* @param v1 - The new tangent vector.
|
|
70
|
+
* @returns A new `Hermite2d` instance with the appended control point and tangent vector.
|
|
71
|
+
* @since 1.0.0
|
|
72
|
+
*/
|
|
27
73
|
(p1: Vector2, v1: Vector2): (p: Hermite2d) => Hermite2d;
|
|
74
|
+
/**
|
|
75
|
+
* Appends a new control point and tangent vector to the Hermite spline.
|
|
76
|
+
*
|
|
77
|
+
* @param p - The `Hermite2d` to append the control point and tangent vector to.
|
|
78
|
+
* @param p1 - The new control point.
|
|
79
|
+
* @param v1 - The new tangent vector.
|
|
80
|
+
* @returns A new `Hermite2d` instance with the appended control point and tangent vector.
|
|
81
|
+
* @since 1.0.0
|
|
82
|
+
*/
|
|
28
83
|
(p: Hermite2d, p1: Vector2, v1: Vector2): Hermite2d;
|
|
29
84
|
};
|
|
85
|
+
declare const prepend: {
|
|
86
|
+
/**
|
|
87
|
+
* Prepends a new control point and tangent vector to the Hermite spline.
|
|
88
|
+
*
|
|
89
|
+
* @param p0 - The new control point.
|
|
90
|
+
* @param v0 - The new tangent vector.
|
|
91
|
+
* @returns A new `Hermite2d` instance with the prepended control point and tangent vector.
|
|
92
|
+
* @since 1.0.0
|
|
93
|
+
*/
|
|
94
|
+
(p0: Vector2, v0: Vector2): (p: Hermite2d) => Hermite2d;
|
|
95
|
+
/**
|
|
96
|
+
* Prepends a new control point and tangent vector to the Hermite spline.
|
|
97
|
+
*
|
|
98
|
+
* @param p - The `Hermite2d` to prepend the control point and tangent vector to.
|
|
99
|
+
* @param p0 - The new control point.
|
|
100
|
+
* @param v0 - The new tangent vector.
|
|
101
|
+
* @returns A new `Hermite2d` instance with the prepended control point and tangent vector.
|
|
102
|
+
* @since 1.0.0
|
|
103
|
+
*/
|
|
104
|
+
(p: Hermite2d, p0: Vector2, v0: Vector2): Hermite2d;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Creates a new `CubicPath2d` instance from a `Hermite2d`.
|
|
108
|
+
*
|
|
109
|
+
* @param p - The `Hermite2d` to convert.
|
|
110
|
+
* @returns A new `CubicPath2d` instance.
|
|
111
|
+
* @since 1.0.0
|
|
112
|
+
*/
|
|
30
113
|
declare const toPath: (p: Hermite2d) => CubicPath2d;
|
|
114
|
+
/**
|
|
115
|
+
* Converts a `Hermite2d` to a `Bezier2d`.
|
|
116
|
+
*
|
|
117
|
+
* @param p - The `Hermite2d` to convert.
|
|
118
|
+
* @returns A new `Bezier2d` instance.
|
|
119
|
+
* @since 1.0.0
|
|
120
|
+
*/
|
|
31
121
|
declare const toBezier: (p: Hermite2d) => Bezier2d;
|
|
32
122
|
|
|
33
|
-
export {
|
|
123
|
+
export { append, characteristic, fromArray, isHermite2d, make, prepend, toBezier, toPath };
|
|
124
|
+
export type { Hermite2d };
|
|
@@ -10,24 +10,115 @@ import '../vector/vector3.js';
|
|
|
10
10
|
import '../matrix/matrix2x2.js';
|
|
11
11
|
import '../curve/cubic2d.js';
|
|
12
12
|
import '../interval.js';
|
|
13
|
-
import '../shared/curvy.
|
|
13
|
+
import '../shared/curvy.Cg8lZVUz.js';
|
|
14
14
|
|
|
15
15
|
declare const Hermite2dTypeId: unique symbol;
|
|
16
16
|
type Hermite2dTypeId = typeof Hermite2dTypeId;
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* A Hermite spline in 2D space.
|
|
20
|
+
*
|
|
21
|
+
* All fields are readonly and immutable, and all operations create new instances.
|
|
22
|
+
*
|
|
23
|
+
* @since 1.0.0
|
|
24
|
+
*/
|
|
18
25
|
interface Hermite2d extends Pipeable {
|
|
19
26
|
readonly [Hermite2dTypeId]: Hermite2dTypeId;
|
|
20
27
|
[Symbol.iterator](): IterableIterator<Vector2>;
|
|
21
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* The characteristic matrix of a Hermite spline.
|
|
31
|
+
*
|
|
32
|
+
* The characteristic matrix is a 4x4 matrix that defines the shape of the spline.
|
|
33
|
+
*
|
|
34
|
+
* @since 1.0.0
|
|
35
|
+
*/
|
|
22
36
|
declare const characteristic: Matrix4x4;
|
|
37
|
+
/**
|
|
38
|
+
* Checks if a value is a `Hermite2d`.
|
|
39
|
+
*
|
|
40
|
+
* @param p - The value to check.
|
|
41
|
+
* @returns `true` if the value is a `Hermite2d`, `false` otherwise.
|
|
42
|
+
* @since 1.0.0
|
|
43
|
+
*/
|
|
44
|
+
declare const isHermite2d: (p: unknown) => p is Hermite2d;
|
|
45
|
+
/**
|
|
46
|
+
* Creates a new `Hermite2d` instance.
|
|
47
|
+
*
|
|
48
|
+
* @param p0 - The first control point.
|
|
49
|
+
* @param v0 - The first tangent vector.
|
|
50
|
+
* @param p1 - The second control point.
|
|
51
|
+
* @param v1 - The second tangent vector.
|
|
52
|
+
* @returns A new `Hermite2d` instance.
|
|
53
|
+
* @since 1.0.0
|
|
54
|
+
*/
|
|
23
55
|
declare const make: (p0: Vector2, v0: Vector2, p1: Vector2, v1: Vector2) => Hermite2d;
|
|
56
|
+
/**
|
|
57
|
+
* Creates a new `Hermite2d` instance from an array of control points.
|
|
58
|
+
*
|
|
59
|
+
* @param points - The control points.
|
|
60
|
+
* @returns A new `Hermite2d` instance.
|
|
61
|
+
* @since 1.0.0
|
|
62
|
+
*/
|
|
24
63
|
declare const fromArray: (points: ReadonlyArray<Vector2>) => Hermite2d;
|
|
25
|
-
declare const isHermite2d: (p: unknown) => p is Hermite2d;
|
|
26
64
|
declare const append: {
|
|
65
|
+
/**
|
|
66
|
+
* Appends a new control point and tangent vector to the Hermite spline.
|
|
67
|
+
*
|
|
68
|
+
* @param p1 - The new control point.
|
|
69
|
+
* @param v1 - The new tangent vector.
|
|
70
|
+
* @returns A new `Hermite2d` instance with the appended control point and tangent vector.
|
|
71
|
+
* @since 1.0.0
|
|
72
|
+
*/
|
|
27
73
|
(p1: Vector2, v1: Vector2): (p: Hermite2d) => Hermite2d;
|
|
74
|
+
/**
|
|
75
|
+
* Appends a new control point and tangent vector to the Hermite spline.
|
|
76
|
+
*
|
|
77
|
+
* @param p - The `Hermite2d` to append the control point and tangent vector to.
|
|
78
|
+
* @param p1 - The new control point.
|
|
79
|
+
* @param v1 - The new tangent vector.
|
|
80
|
+
* @returns A new `Hermite2d` instance with the appended control point and tangent vector.
|
|
81
|
+
* @since 1.0.0
|
|
82
|
+
*/
|
|
28
83
|
(p: Hermite2d, p1: Vector2, v1: Vector2): Hermite2d;
|
|
29
84
|
};
|
|
85
|
+
declare const prepend: {
|
|
86
|
+
/**
|
|
87
|
+
* Prepends a new control point and tangent vector to the Hermite spline.
|
|
88
|
+
*
|
|
89
|
+
* @param p0 - The new control point.
|
|
90
|
+
* @param v0 - The new tangent vector.
|
|
91
|
+
* @returns A new `Hermite2d` instance with the prepended control point and tangent vector.
|
|
92
|
+
* @since 1.0.0
|
|
93
|
+
*/
|
|
94
|
+
(p0: Vector2, v0: Vector2): (p: Hermite2d) => Hermite2d;
|
|
95
|
+
/**
|
|
96
|
+
* Prepends a new control point and tangent vector to the Hermite spline.
|
|
97
|
+
*
|
|
98
|
+
* @param p - The `Hermite2d` to prepend the control point and tangent vector to.
|
|
99
|
+
* @param p0 - The new control point.
|
|
100
|
+
* @param v0 - The new tangent vector.
|
|
101
|
+
* @returns A new `Hermite2d` instance with the prepended control point and tangent vector.
|
|
102
|
+
* @since 1.0.0
|
|
103
|
+
*/
|
|
104
|
+
(p: Hermite2d, p0: Vector2, v0: Vector2): Hermite2d;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Creates a new `CubicPath2d` instance from a `Hermite2d`.
|
|
108
|
+
*
|
|
109
|
+
* @param p - The `Hermite2d` to convert.
|
|
110
|
+
* @returns A new `CubicPath2d` instance.
|
|
111
|
+
* @since 1.0.0
|
|
112
|
+
*/
|
|
30
113
|
declare const toPath: (p: Hermite2d) => CubicPath2d;
|
|
114
|
+
/**
|
|
115
|
+
* Converts a `Hermite2d` to a `Bezier2d`.
|
|
116
|
+
*
|
|
117
|
+
* @param p - The `Hermite2d` to convert.
|
|
118
|
+
* @returns A new `Bezier2d` instance.
|
|
119
|
+
* @since 1.0.0
|
|
120
|
+
*/
|
|
31
121
|
declare const toBezier: (p: Hermite2d) => Bezier2d;
|
|
32
122
|
|
|
33
|
-
export {
|
|
123
|
+
export { append, characteristic, fromArray, isHermite2d, make, prepend, toBezier, toPath };
|
|
124
|
+
export type { Hermite2d };
|
|
@@ -2,57 +2,37 @@ import { make as make$2 } from '../matrix/matrix4x4.mjs';
|
|
|
2
2
|
import { fromCurves } from '../path/cubic2d.mjs';
|
|
3
3
|
import { dual, Pipeable } from '../pipe.mjs';
|
|
4
4
|
import { invariant } from '../utils.mjs';
|
|
5
|
-
import {
|
|
6
|
-
import '../shared/curvy.
|
|
7
|
-
import '../shared/curvy.
|
|
8
|
-
import '../shared/curvy.
|
|
9
|
-
import '../shared/curvy.
|
|
10
|
-
import '../shared/curvy.
|
|
5
|
+
import { f as fromSpline, t as toCurves } from '../shared/curvy.DCt1gGII.mjs';
|
|
6
|
+
import '../shared/curvy.BkkW8Tx9.mjs';
|
|
7
|
+
import '../shared/curvy.DJ4xO0al.mjs';
|
|
8
|
+
import '../shared/curvy.C_sCeg9J.mjs';
|
|
9
|
+
import '../shared/curvy.lktriTpx.mjs';
|
|
10
|
+
import '../shared/curvy.mLFprrGm.mjs';
|
|
11
11
|
import '../curve/cubic2d.mjs';
|
|
12
12
|
import '../interval.mjs';
|
|
13
13
|
import '../shared/curvy.DmVFTi0N.mjs';
|
|
14
14
|
import '../polynomial/cubic.mjs';
|
|
15
|
-
import '../shared/curvy.
|
|
16
|
-
import '../shared/curvy.BDhiZ7He.mjs';
|
|
17
|
-
import '../polynomial/quadratic.mjs';
|
|
15
|
+
import '../shared/curvy.BxdGW9he.mjs';
|
|
18
16
|
import '../vector/vector2.mjs';
|
|
17
|
+
import '../shared/curvy.r6f1j287.mjs';
|
|
18
|
+
import '../polynomial/quadratic.mjs';
|
|
19
19
|
import '../curve/linear2d.mjs';
|
|
20
20
|
import '../polynomial/linear.mjs';
|
|
21
21
|
import '../curve/quadratic2d.mjs';
|
|
22
22
|
import '../vector/vector4.mjs';
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
0,
|
|
27
|
-
0,
|
|
28
|
-
0,
|
|
29
|
-
0,
|
|
30
|
-
1,
|
|
31
|
-
0,
|
|
32
|
-
0,
|
|
33
|
-
-3,
|
|
34
|
-
-2,
|
|
35
|
-
3,
|
|
36
|
-
-1,
|
|
37
|
-
2,
|
|
38
|
-
1,
|
|
39
|
-
-2,
|
|
40
|
-
1
|
|
41
|
-
);
|
|
24
|
+
var _a;
|
|
25
|
+
const characteristic$1 = make$2(1, 0, 0, 0, 0, 1, 0, 0, -3, -2, 3, -1, 2, 1, -2, 1);
|
|
42
26
|
const Hermite2dTypeId = Symbol("curvy/splines/hermite2d");
|
|
43
27
|
class Hermite2dImpl extends Pipeable {
|
|
44
|
-
[Hermite2dTypeId] = Hermite2dTypeId;
|
|
45
|
-
points;
|
|
46
28
|
constructor(points) {
|
|
47
29
|
invariant(points.length >= 4, "hermite splines requires 4 or more points");
|
|
48
|
-
invariant(
|
|
49
|
-
points.length % 2 === 0,
|
|
50
|
-
"hermite splines requires (n * 2) points"
|
|
51
|
-
);
|
|
30
|
+
invariant(points.length % 2 === 0, "hermite splines requires (n * 2) points");
|
|
52
31
|
super();
|
|
32
|
+
this[_a] = Hermite2dTypeId;
|
|
53
33
|
this.points = points;
|
|
54
34
|
}
|
|
55
|
-
[Symbol.iterator]() {
|
|
35
|
+
[(_a = Hermite2dTypeId, Symbol.iterator)]() {
|
|
56
36
|
return this.points[Symbol.iterator]();
|
|
57
37
|
}
|
|
58
38
|
}
|
|
@@ -63,15 +43,21 @@ const append$1 = dual(3, (p, p1, v1) => {
|
|
|
63
43
|
const points = p instanceof Hermite2dImpl ? p.points : Array.from(p);
|
|
64
44
|
return new Hermite2dImpl(points.concat(p1, v1));
|
|
65
45
|
});
|
|
46
|
+
const prepend$1 = dual(3, (p, p0, v0) => {
|
|
47
|
+
const points = p instanceof Hermite2dImpl ? p.points : Array.from(p);
|
|
48
|
+
return new Hermite2dImpl([p0, v0].concat(points));
|
|
49
|
+
});
|
|
66
50
|
const toPath$1 = (p) => fromCurves(...toCurves(p, characteristic$1, 2));
|
|
67
51
|
const toBezier$1 = (p) => fromSpline(p, characteristic$1, 2);
|
|
68
52
|
|
|
69
53
|
const characteristic = characteristic$1;
|
|
54
|
+
const isHermite2d = isHermite2d$1;
|
|
70
55
|
const make = make$1;
|
|
71
56
|
const fromArray = fromArray$1;
|
|
72
|
-
const isHermite2d = isHermite2d$1;
|
|
73
57
|
const append = append$1;
|
|
58
|
+
const prepend = prepend$1;
|
|
74
59
|
const toPath = toPath$1;
|
|
75
60
|
const toBezier = toBezier$1;
|
|
76
61
|
|
|
77
|
-
export { append, characteristic, fromArray, isHermite2d, make, toBezier, toPath };
|
|
62
|
+
export { append, characteristic, fromArray, isHermite2d, make, prepend, toBezier, toPath };
|
|
63
|
+
//# sourceMappingURL=hermite2d.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hermite2d.mjs","sources":["../../src/splines/hermite2d.internal.ts","../../src/splines/hermite2d.ts"],"sourcesContent":["import * as Matrix4x4 from '../matrix/matrix4x4'\nimport * as CubicPath2d from '../path/cubic2d'\nimport { Pipeable } from '../pipe'\nimport { dual } from '../pipe'\nimport { invariant } from '../utils'\nimport type * as Vector2 from '../vector/vector2'\nimport * as Bezier2d from './bezier2d'\nimport type { Hermite2d } from './hermite2d'\nimport { toCurves } from './util'\n\nexport const characteristic = Matrix4x4.make(1, 0, 0, 0, 0, 1, 0, 0, -3, -2, 3, -1, 2, 1, -2, 1)\n\nexport const Hermite2dTypeId = Symbol('curvy/splines/hermite2d')\nexport type Hermite2dTypeId = typeof Hermite2dTypeId\n\nclass Hermite2dImpl extends Pipeable implements Hermite2d {\n readonly [Hermite2dTypeId]: Hermite2dTypeId = Hermite2dTypeId\n\n readonly points: ReadonlyArray<Vector2.Vector2>\n\n constructor(points: ReadonlyArray<Vector2.Vector2>) {\n invariant(points.length >= 4, 'hermite splines requires 4 or more points')\n invariant(points.length % 2 === 0, 'hermite splines requires (n * 2) points')\n\n super()\n this.points = points\n }\n\n [Symbol.iterator]() {\n return this.points[Symbol.iterator]()\n }\n}\n\nexport const isHermite2d = (p: unknown): p is Hermite2d =>\n typeof p === 'object' && p !== null && Hermite2dTypeId in p\n\nexport const make = (\n p0: Vector2.Vector2,\n v0: Vector2.Vector2,\n p1: Vector2.Vector2,\n v1: Vector2.Vector2,\n) => new Hermite2dImpl([p0, v0, p1, v1])\n\nexport const fromArray = (points: ReadonlyArray<Vector2.Vector2>) => new Hermite2dImpl(points)\n\nexport const append = dual<\n (p1: Vector2.Vector2, v1: Vector2.Vector2) => (p: Hermite2d) => Hermite2d,\n (p: Hermite2d, p1: Vector2.Vector2, v1: Vector2.Vector2) => Hermite2d\n>(3, (p: Hermite2d, p1: Vector2.Vector2, v1: Vector2.Vector2) => {\n const points = p instanceof Hermite2dImpl ? p.points : Array.from(p)\n return new Hermite2dImpl(points.concat(p1, v1))\n})\n\nexport const prepend = dual<\n (p0: Vector2.Vector2, v0: Vector2.Vector2) => (p: Hermite2d) => Hermite2d,\n (p: Hermite2d, p0: Vector2.Vector2, v0: Vector2.Vector2) => Hermite2d\n>(3, (p: Hermite2d, p0: Vector2.Vector2, v0: Vector2.Vector2) => {\n const points = p instanceof Hermite2dImpl ? p.points : Array.from(p)\n return new Hermite2dImpl([p0, v0].concat(points))\n})\n\nexport const toPath = (p: Hermite2d) => CubicPath2d.fromCurves(...toCurves(p, characteristic, 2))\n\nexport const toBezier = (p: Hermite2d) => Bezier2d.fromSpline(p, characteristic, 2)\n","import type { Matrix4x4 } from '../matrix/matrix4x4'\nimport type { CubicPath2d } from '../path/cubic2d'\nimport type { Pipeable } from '../pipe'\nimport type { Vector2 } from '../vector/vector2'\nimport type { Bezier2d } from './bezier2d'\nimport { Hermite2dTypeId } from './hermite2d.internal'\nimport * as internal from './hermite2d.internal'\n\n/**\n * A Hermite spline in 2D space.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * @since 1.0.0\n */\nexport interface Hermite2d extends Pipeable {\n readonly [Hermite2dTypeId]: Hermite2dTypeId\n\n [Symbol.iterator](): IterableIterator<Vector2>\n}\n\n/**\n * The characteristic matrix of a Hermite spline.\n *\n * The characteristic matrix is a 4x4 matrix that defines the shape of the spline.\n *\n * @since 1.0.0\n */\nexport const characteristic: Matrix4x4 = internal.characteristic\n\n/**\n * Checks if a value is a `Hermite2d`.\n *\n * @param p - The value to check.\n * @returns `true` if the value is a `Hermite2d`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isHermite2d: (p: unknown) => p is Hermite2d = internal.isHermite2d\n\n/**\n * Creates a new `Hermite2d` instance.\n *\n * @param p0 - The first control point.\n * @param v0 - The first tangent vector.\n * @param p1 - The second control point.\n * @param v1 - The second tangent vector.\n * @returns A new `Hermite2d` instance.\n * @since 1.0.0\n */\nexport const make: (p0: Vector2, v0: Vector2, p1: Vector2, v1: Vector2) => Hermite2d = internal.make\n\n/**\n * Creates a new `Hermite2d` instance from an array of control points.\n *\n * @param points - The control points.\n * @returns A new `Hermite2d` instance.\n * @since 1.0.0\n */\nexport const fromArray: (points: ReadonlyArray<Vector2>) => Hermite2d = internal.fromArray\n\nexport const append: {\n /**\n * Appends a new control point and tangent vector to the Hermite spline.\n *\n * @param p1 - The new control point.\n * @param v1 - The new tangent vector.\n * @returns A new `Hermite2d` instance with the appended control point and tangent vector.\n * @since 1.0.0\n */\n (p1: Vector2, v1: Vector2): (p: Hermite2d) => Hermite2d\n /**\n * Appends a new control point and tangent vector to the Hermite spline.\n *\n * @param p - The `Hermite2d` to append the control point and tangent vector to.\n * @param p1 - The new control point.\n * @param v1 - The new tangent vector.\n * @returns A new `Hermite2d` instance with the appended control point and tangent vector.\n * @since 1.0.0\n */\n (p: Hermite2d, p1: Vector2, v1: Vector2): Hermite2d\n} = internal.append\n\nexport const prepend: {\n /**\n * Prepends a new control point and tangent vector to the Hermite spline.\n *\n * @param p0 - The new control point.\n * @param v0 - The new tangent vector.\n * @returns A new `Hermite2d` instance with the prepended control point and tangent vector.\n * @since 1.0.0\n */\n (p0: Vector2, v0: Vector2): (p: Hermite2d) => Hermite2d\n /**\n * Prepends a new control point and tangent vector to the Hermite spline.\n *\n * @param p - The `Hermite2d` to prepend the control point and tangent vector to.\n * @param p0 - The new control point.\n * @param v0 - The new tangent vector.\n * @returns A new `Hermite2d` instance with the prepended control point and tangent vector.\n * @since 1.0.0\n */\n (p: Hermite2d, p0: Vector2, v0: Vector2): Hermite2d\n} = internal.prepend\n\n/**\n * Creates a new `CubicPath2d` instance from a `Hermite2d`.\n *\n * @param p - The `Hermite2d` to convert.\n * @returns A new `CubicPath2d` instance.\n * @since 1.0.0\n */\nexport const toPath: (p: Hermite2d) => CubicPath2d = internal.toPath\n\n/**\n * Converts a `Hermite2d` to a `Bezier2d`.\n *\n * @param p - The `Hermite2d` to convert.\n * @returns A new `Bezier2d` instance.\n * @since 1.0.0\n */\nexport const toBezier: (p: Hermite2d) => Bezier2d = internal.toBezier\n"],"names":["characteristic","Matrix4x4.make","isHermite2d","make","fromArray","append","prepend","toPath","CubicPath2d.fromCurves","toBezier","Bezier2d.fromSpline","internal.characteristic","internal.isHermite2d","internal.make","internal.fromArray","internal.append","internal.prepend","internal.toPath","internal.toBezier"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAA,EAAA;AAUO,MAAMA,mBAAiBC,MAAU,CAAK,GAAG,CAAG,EAAA,CAAA,EAAG,GAAG,CAAG,EAAA,CAAA,EAAG,CAAG,EAAA,CAAA,EAAG,IAAI,EAAI,EAAA,CAAA,EAAG,IAAI,CAAG,EAAA,CAAA,EAAG,IAAI,CAAC,CAAA;AAElF,MAAA,eAAA,GAAkB,OAAO,yBAAyB,CAAA;AAG/D,MAAM,sBAAsB,QAA8B,CAAA;AAAA,EAKxD,YAAY,MAAwC,EAAA;AAClD,IAAU,SAAA,CAAA,MAAA,CAAO,MAAU,IAAA,CAAA,EAAG,2CAA2C,CAAA;AACzE,IAAA,SAAA,CAAU,MAAO,CAAA,MAAA,GAAS,CAAM,KAAA,CAAA,EAAG,yCAAyC,CAAA;AAE5E,IAAM,KAAA,EAAA;AARR,IAAA,IAAA,CAAU,EAAoC,CAAA,GAAA,eAAA;AAS5C,IAAA,IAAA,CAAK,MAAS,GAAA,MAAA;AAAA;AAChB,EAEA,EAZU,EAAA,GAAA,eAAA,EAYT,MAAO,CAAA,QAAA,EAAY,GAAA;AAClB,IAAA,OAAO,IAAK,CAAA,MAAA,CAAO,MAAO,CAAA,QAAQ,CAAE,EAAA;AAAA;AAExC;AAEa,MAAAC,aAAA,GAAc,CAAC,CAC1B,KAAA,OAAO,MAAM,QAAY,IAAA,CAAA,KAAM,QAAQ,eAAmB,IAAA,CAAA;AAErD,MAAMC,MAAO,GAAA,CAClB,EACA,EAAA,EAAA,EACA,EACA,EAAA,EAAA,KACG,IAAI,aAAA,CAAc,CAAC,EAAA,EAAI,EAAI,EAAA,EAAA,EAAI,EAAE,CAAC,CAAA;AAEhC,MAAMC,WAAY,GAAA,CAAC,MAA2C,KAAA,IAAI,cAAc,MAAM,CAAA;A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