curvy 0.3.2 → 1.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.
Files changed (93) hide show
  1. package/LICENSE.md +21 -0
  2. package/dist/curve/cubic2d.d.mts +27 -0
  3. package/dist/curve/cubic2d.d.ts +27 -0
  4. package/dist/curve/cubic2d.mjs +85 -0
  5. package/dist/curve/linear2d.d.mts +27 -0
  6. package/dist/curve/linear2d.d.ts +27 -0
  7. package/dist/curve/linear2d.mjs +46 -0
  8. package/dist/curve/quadratic2d.d.mts +27 -0
  9. package/dist/curve/quadratic2d.d.ts +27 -0
  10. package/dist/curve/quadratic2d.mjs +74 -0
  11. package/dist/interval.d.mts +58 -0
  12. package/dist/interval.d.ts +58 -0
  13. package/dist/interval.mjs +88 -0
  14. package/dist/matrix/matrix2x2.d.mts +49 -0
  15. package/dist/matrix/matrix2x2.d.ts +49 -0
  16. package/dist/matrix/matrix2x2.mjs +23 -0
  17. package/dist/matrix/matrix3x3.d.mts +63 -0
  18. package/dist/matrix/matrix3x3.d.ts +63 -0
  19. package/dist/matrix/matrix3x3.mjs +26 -0
  20. package/dist/matrix/matrix4x4.d.mts +72 -0
  21. package/dist/matrix/matrix4x4.d.ts +72 -0
  22. package/dist/matrix/matrix4x4.mjs +214 -0
  23. package/dist/path/cubic2d.d.mts +29 -0
  24. package/dist/path/cubic2d.d.ts +29 -0
  25. package/dist/path/cubic2d.mjs +60 -0
  26. package/dist/path/linear2d.d.mts +29 -0
  27. package/dist/path/linear2d.d.ts +29 -0
  28. package/dist/path/linear2d.mjs +54 -0
  29. package/dist/path/quadratic2d.d.mts +29 -0
  30. package/dist/path/quadratic2d.d.ts +29 -0
  31. package/dist/path/quadratic2d.mjs +60 -0
  32. package/dist/polynomial/cubic.d.mts +7 -0
  33. package/dist/polynomial/cubic.d.ts +7 -0
  34. package/dist/polynomial/cubic.mjs +139 -0
  35. package/dist/polynomial/linear.d.mts +7 -0
  36. package/dist/polynomial/linear.d.ts +7 -0
  37. package/dist/polynomial/linear.mjs +19 -0
  38. package/dist/polynomial/quadratic.d.mts +7 -0
  39. package/dist/polynomial/quadratic.d.ts +7 -0
  40. package/dist/polynomial/quadratic.mjs +22 -0
  41. package/dist/shared/curvy.BAW_cKLu.mjs +123 -0
  42. package/dist/shared/curvy.BN-oFBsc.d.mts +26 -0
  43. package/dist/shared/curvy.BN-oFBsc.d.ts +26 -0
  44. package/dist/shared/curvy.Bxxwly94.d.mts +144 -0
  45. package/dist/shared/curvy.C-sUk7ux.mjs +119 -0
  46. package/dist/shared/curvy.CLzGuqek.mjs +124 -0
  47. package/dist/shared/curvy.CO0Wclt0.d.ts +144 -0
  48. package/dist/shared/curvy.CT38g_II.d.mts +22 -0
  49. package/dist/shared/curvy.CT38g_II.d.ts +22 -0
  50. package/dist/shared/curvy.ChkqgKuv.mjs +119 -0
  51. package/dist/shared/curvy.Cty3LrOR.mjs +70 -0
  52. package/dist/shared/curvy.D7bhnwZy.mjs +52 -0
  53. package/dist/shared/curvy.DOLqYbKE.mjs +48 -0
  54. package/dist/shared/curvy.DgRsieUW.mjs +76 -0
  55. package/dist/shared/curvy.DmVFTi0N.mjs +34 -0
  56. package/dist/splines/bezier2d.d.mts +35 -0
  57. package/dist/splines/bezier2d.d.ts +35 -0
  58. package/dist/splines/bezier2d.mjs +122 -0
  59. package/dist/vector/vector2.d.mts +37 -0
  60. package/dist/vector/vector2.d.ts +37 -0
  61. package/dist/vector/vector2.mjs +16 -0
  62. package/dist/vector/vector3.d.mts +38 -0
  63. package/dist/vector/vector3.d.ts +38 -0
  64. package/dist/vector/vector3.mjs +16 -0
  65. package/dist/vector/vector4.d.mts +39 -0
  66. package/dist/vector/vector4.d.ts +39 -0
  67. package/dist/vector/vector4.mjs +16 -0
  68. package/package.json +81 -38
  69. package/dist/axis.cjs +0 -325
  70. package/dist/axis.d.cts +0 -20
  71. package/dist/axis.d.mts +0 -20
  72. package/dist/axis.d.ts +0 -20
  73. package/dist/axis.mjs +0 -314
  74. package/dist/convert.cjs +0 -74
  75. package/dist/convert.d.cts +0 -6
  76. package/dist/convert.d.mts +0 -6
  77. package/dist/convert.d.ts +0 -6
  78. package/dist/convert.mjs +0 -68
  79. package/dist/curve.cjs +0 -194
  80. package/dist/curve.d.cts +0 -18
  81. package/dist/curve.d.mts +0 -18
  82. package/dist/curve.d.ts +0 -18
  83. package/dist/curve.mjs +0 -184
  84. package/dist/shared/curvy.262f6070.cjs +0 -16
  85. package/dist/shared/curvy.9cd8b44c.mjs +0 -13
  86. package/dist/shared/curvy.df73166c.d.cts +0 -38
  87. package/dist/shared/curvy.df73166c.d.mts +0 -38
  88. package/dist/shared/curvy.df73166c.d.ts +0 -38
  89. package/dist/splines.cjs +0 -150
  90. package/dist/splines.d.cts +0 -27
  91. package/dist/splines.d.mts +0 -27
  92. package/dist/splines.d.ts +0 -27
  93. package/dist/splines.mjs +0 -138
package/dist/splines.cjs DELETED
@@ -1,150 +0,0 @@
1
- 'use strict';
2
-
3
- const invariant = require('tiny-invariant');
4
-
5
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
6
-
7
- const invariant__default = /*#__PURE__*/_interopDefaultCompat(invariant);
8
-
9
- function chunkPointsBy(values, stride) {
10
- const chunks = [];
11
- invariant__default(values.length >= 4, "Values must have at least 4 elements");
12
- invariant__default(
13
- stride === 1 || stride === 2 || stride === 3,
14
- "Stride must be 1, 2, or 3"
15
- );
16
- if (stride === 3) {
17
- invariant__default(
18
- values.length % stride === 1,
19
- "Values length must be a multiple of 3 plus 1"
20
- );
21
- } else {
22
- invariant__default(
23
- values.length % stride === 0,
24
- `Values length must be a multiple of ${stride}`
25
- );
26
- }
27
- for (let i = 0; i <= values.length - 4; i += stride) {
28
- chunks.push([
29
- values[i],
30
- values[i + 1],
31
- values[i + 2],
32
- values[i + 3]
33
- ]);
34
- }
35
- return chunks;
36
- }
37
- function pointsToCoefficients(matrix, parameters) {
38
- return [
39
- parameters[0] * matrix[0][0] + parameters[1] * matrix[0][1] + parameters[2] * matrix[0][2] + parameters[3] * matrix[0][3],
40
- parameters[0] * matrix[1][0] + parameters[1] * matrix[1][1] + parameters[2] * matrix[1][2] + parameters[3] * matrix[1][3],
41
- parameters[0] * matrix[2][0] + parameters[1] * matrix[2][1] + parameters[2] * matrix[2][2] + parameters[3] * matrix[2][3],
42
- parameters[0] * matrix[3][0] + parameters[1] * matrix[3][1] + parameters[2] * matrix[3][2] + parameters[3] * matrix[3][3]
43
- ];
44
- }
45
- const bezier = {
46
- matrix: [
47
- [-1, 3, -3, 1],
48
- [3, -6, 3, 0],
49
- [-3, 3, 0, 0],
50
- [1, 0, 0, 0]
51
- ],
52
- chunkCoefficients(parameters) {
53
- const coefficients = [];
54
- for (const chunk of chunkPointsBy(parameters, 3)) {
55
- coefficients.push(pointsToCoefficients(this.matrix, chunk));
56
- }
57
- return coefficients;
58
- }
59
- };
60
- const hermite = {
61
- matrix: [
62
- [2, 1, -2, 1],
63
- [-3, -2, 3, -1],
64
- [0, 1, 0, 0],
65
- [1, 0, 0, 0]
66
- ],
67
- chunkCoefficients(parameters) {
68
- const coefficients = [];
69
- for (const chunk of chunkPointsBy(parameters, 2)) {
70
- coefficients.push(pointsToCoefficients(this.matrix, chunk));
71
- }
72
- return coefficients;
73
- }
74
- };
75
- const cardinal = (a, duplicateEndpoints = true) => ({
76
- matrix: [
77
- [-a, 2 - a, a - 2, a],
78
- [2 * a, a - 3, 3 - 2 * a, -a],
79
- [-a, 0, a, 0],
80
- [0, 1, 0, 0]
81
- ],
82
- chunkCoefficients(parameters) {
83
- const coefficients = [];
84
- for (const chunk of chunkPointsBy(
85
- duplicateEndpoints ? [parameters[0], ...parameters, parameters[parameters.length - 1]] : parameters,
86
- 1
87
- )) {
88
- coefficients.push(pointsToCoefficients(this.matrix, chunk));
89
- }
90
- return coefficients;
91
- }
92
- });
93
- const catmullRom = (duplicateEndpoints = true) => ({
94
- matrix: [
95
- [-0.5, 1.5, -1.5, 0.5],
96
- [1, -2.5, 2, -0.5],
97
- [-0.5, 0, 0.5, 0],
98
- [0, 1, 0, 0]
99
- ],
100
- chunkCoefficients(parameters) {
101
- const coefficients = [];
102
- for (const chunk of chunkPointsBy(
103
- duplicateEndpoints ? [parameters[0], ...parameters, parameters[parameters.length - 1]] : parameters,
104
- 1
105
- )) {
106
- coefficients.push(pointsToCoefficients(this.matrix, chunk));
107
- }
108
- return coefficients;
109
- }
110
- });
111
- const ONE_SIXTH = 1 / 6;
112
- const basis = (triplicateEndpoints = true) => ({
113
- matrix: [
114
- [-ONE_SIXTH, 0.5, -0.5, ONE_SIXTH],
115
- [0.5, -1, 0.5, 0],
116
- [-0.5, 0, 0.5, 0],
117
- [ONE_SIXTH, 4 * ONE_SIXTH, ONE_SIXTH, 0]
118
- ],
119
- chunkCoefficients(parameters) {
120
- const coefficients = [];
121
- for (const chunk of chunkPointsBy(
122
- triplicateEndpoints ? [
123
- parameters[0],
124
- parameters[0],
125
- ...parameters,
126
- parameters[parameters.length - 1],
127
- parameters[parameters.length - 1]
128
- ] : parameters,
129
- 1
130
- )) {
131
- coefficients.push(pointsToCoefficients(this.matrix, chunk));
132
- }
133
- return coefficients;
134
- }
135
- });
136
- const splines = {
137
- basis,
138
- bezier,
139
- cardinal,
140
- catmullRom,
141
- hermite
142
- };
143
-
144
- exports.basis = basis;
145
- exports.bezier = bezier;
146
- exports.cardinal = cardinal;
147
- exports.catmullRom = catmullRom;
148
- exports.hermite = hermite;
149
- exports.pointsToCoefficients = pointsToCoefficients;
150
- exports.splines = splines;
@@ -1,27 +0,0 @@
1
- import { a as CubicCoefficients } from './shared/curvy.df73166c.cjs';
2
-
3
- type Matrix4x4 = readonly [
4
- CubicCoefficients,
5
- CubicCoefficients,
6
- CubicCoefficients,
7
- CubicCoefficients
8
- ];
9
- type Spline = {
10
- matrix: Matrix4x4;
11
- chunkCoefficients: (parameters: ReadonlyArray<number>) => ReadonlyArray<CubicCoefficients>;
12
- };
13
- declare function pointsToCoefficients(matrix: Matrix4x4, parameters: CubicCoefficients): CubicCoefficients;
14
- declare const bezier: Spline;
15
- declare const hermite: Spline;
16
- declare const cardinal: (a: number, duplicateEndpoints?: boolean) => Spline;
17
- declare const catmullRom: (duplicateEndpoints?: boolean) => Spline;
18
- declare const basis: (triplicateEndpoints?: boolean) => Spline;
19
- declare const splines: {
20
- readonly basis: (triplicateEndpoints?: boolean) => Spline;
21
- readonly bezier: Spline;
22
- readonly cardinal: (a: number, duplicateEndpoints?: boolean) => Spline;
23
- readonly catmullRom: (duplicateEndpoints?: boolean) => Spline;
24
- readonly hermite: Spline;
25
- };
26
-
27
- export { type Matrix4x4, type Spline, basis, bezier, cardinal, catmullRom, hermite, pointsToCoefficients, splines };
@@ -1,27 +0,0 @@
1
- import { a as CubicCoefficients } from './shared/curvy.df73166c.mjs';
2
-
3
- type Matrix4x4 = readonly [
4
- CubicCoefficients,
5
- CubicCoefficients,
6
- CubicCoefficients,
7
- CubicCoefficients
8
- ];
9
- type Spline = {
10
- matrix: Matrix4x4;
11
- chunkCoefficients: (parameters: ReadonlyArray<number>) => ReadonlyArray<CubicCoefficients>;
12
- };
13
- declare function pointsToCoefficients(matrix: Matrix4x4, parameters: CubicCoefficients): CubicCoefficients;
14
- declare const bezier: Spline;
15
- declare const hermite: Spline;
16
- declare const cardinal: (a: number, duplicateEndpoints?: boolean) => Spline;
17
- declare const catmullRom: (duplicateEndpoints?: boolean) => Spline;
18
- declare const basis: (triplicateEndpoints?: boolean) => Spline;
19
- declare const splines: {
20
- readonly basis: (triplicateEndpoints?: boolean) => Spline;
21
- readonly bezier: Spline;
22
- readonly cardinal: (a: number, duplicateEndpoints?: boolean) => Spline;
23
- readonly catmullRom: (duplicateEndpoints?: boolean) => Spline;
24
- readonly hermite: Spline;
25
- };
26
-
27
- export { type Matrix4x4, type Spline, basis, bezier, cardinal, catmullRom, hermite, pointsToCoefficients, splines };
package/dist/splines.d.ts DELETED
@@ -1,27 +0,0 @@
1
- import { a as CubicCoefficients } from './shared/curvy.df73166c.js';
2
-
3
- type Matrix4x4 = readonly [
4
- CubicCoefficients,
5
- CubicCoefficients,
6
- CubicCoefficients,
7
- CubicCoefficients
8
- ];
9
- type Spline = {
10
- matrix: Matrix4x4;
11
- chunkCoefficients: (parameters: ReadonlyArray<number>) => ReadonlyArray<CubicCoefficients>;
12
- };
13
- declare function pointsToCoefficients(matrix: Matrix4x4, parameters: CubicCoefficients): CubicCoefficients;
14
- declare const bezier: Spline;
15
- declare const hermite: Spline;
16
- declare const cardinal: (a: number, duplicateEndpoints?: boolean) => Spline;
17
- declare const catmullRom: (duplicateEndpoints?: boolean) => Spline;
18
- declare const basis: (triplicateEndpoints?: boolean) => Spline;
19
- declare const splines: {
20
- readonly basis: (triplicateEndpoints?: boolean) => Spline;
21
- readonly bezier: Spline;
22
- readonly cardinal: (a: number, duplicateEndpoints?: boolean) => Spline;
23
- readonly catmullRom: (duplicateEndpoints?: boolean) => Spline;
24
- readonly hermite: Spline;
25
- };
26
-
27
- export { type Matrix4x4, type Spline, basis, bezier, cardinal, catmullRom, hermite, pointsToCoefficients, splines };
package/dist/splines.mjs DELETED
@@ -1,138 +0,0 @@
1
- import invariant from 'tiny-invariant';
2
-
3
- function chunkPointsBy(values, stride) {
4
- const chunks = [];
5
- invariant(values.length >= 4, "Values must have at least 4 elements");
6
- invariant(
7
- stride === 1 || stride === 2 || stride === 3,
8
- "Stride must be 1, 2, or 3"
9
- );
10
- if (stride === 3) {
11
- invariant(
12
- values.length % stride === 1,
13
- "Values length must be a multiple of 3 plus 1"
14
- );
15
- } else {
16
- invariant(
17
- values.length % stride === 0,
18
- `Values length must be a multiple of ${stride}`
19
- );
20
- }
21
- for (let i = 0; i <= values.length - 4; i += stride) {
22
- chunks.push([
23
- values[i],
24
- values[i + 1],
25
- values[i + 2],
26
- values[i + 3]
27
- ]);
28
- }
29
- return chunks;
30
- }
31
- function pointsToCoefficients(matrix, parameters) {
32
- return [
33
- parameters[0] * matrix[0][0] + parameters[1] * matrix[0][1] + parameters[2] * matrix[0][2] + parameters[3] * matrix[0][3],
34
- parameters[0] * matrix[1][0] + parameters[1] * matrix[1][1] + parameters[2] * matrix[1][2] + parameters[3] * matrix[1][3],
35
- parameters[0] * matrix[2][0] + parameters[1] * matrix[2][1] + parameters[2] * matrix[2][2] + parameters[3] * matrix[2][3],
36
- parameters[0] * matrix[3][0] + parameters[1] * matrix[3][1] + parameters[2] * matrix[3][2] + parameters[3] * matrix[3][3]
37
- ];
38
- }
39
- const bezier = {
40
- matrix: [
41
- [-1, 3, -3, 1],
42
- [3, -6, 3, 0],
43
- [-3, 3, 0, 0],
44
- [1, 0, 0, 0]
45
- ],
46
- chunkCoefficients(parameters) {
47
- const coefficients = [];
48
- for (const chunk of chunkPointsBy(parameters, 3)) {
49
- coefficients.push(pointsToCoefficients(this.matrix, chunk));
50
- }
51
- return coefficients;
52
- }
53
- };
54
- const hermite = {
55
- matrix: [
56
- [2, 1, -2, 1],
57
- [-3, -2, 3, -1],
58
- [0, 1, 0, 0],
59
- [1, 0, 0, 0]
60
- ],
61
- chunkCoefficients(parameters) {
62
- const coefficients = [];
63
- for (const chunk of chunkPointsBy(parameters, 2)) {
64
- coefficients.push(pointsToCoefficients(this.matrix, chunk));
65
- }
66
- return coefficients;
67
- }
68
- };
69
- const cardinal = (a, duplicateEndpoints = true) => ({
70
- matrix: [
71
- [-a, 2 - a, a - 2, a],
72
- [2 * a, a - 3, 3 - 2 * a, -a],
73
- [-a, 0, a, 0],
74
- [0, 1, 0, 0]
75
- ],
76
- chunkCoefficients(parameters) {
77
- const coefficients = [];
78
- for (const chunk of chunkPointsBy(
79
- duplicateEndpoints ? [parameters[0], ...parameters, parameters[parameters.length - 1]] : parameters,
80
- 1
81
- )) {
82
- coefficients.push(pointsToCoefficients(this.matrix, chunk));
83
- }
84
- return coefficients;
85
- }
86
- });
87
- const catmullRom = (duplicateEndpoints = true) => ({
88
- matrix: [
89
- [-0.5, 1.5, -1.5, 0.5],
90
- [1, -2.5, 2, -0.5],
91
- [-0.5, 0, 0.5, 0],
92
- [0, 1, 0, 0]
93
- ],
94
- chunkCoefficients(parameters) {
95
- const coefficients = [];
96
- for (const chunk of chunkPointsBy(
97
- duplicateEndpoints ? [parameters[0], ...parameters, parameters[parameters.length - 1]] : parameters,
98
- 1
99
- )) {
100
- coefficients.push(pointsToCoefficients(this.matrix, chunk));
101
- }
102
- return coefficients;
103
- }
104
- });
105
- const ONE_SIXTH = 1 / 6;
106
- const basis = (triplicateEndpoints = true) => ({
107
- matrix: [
108
- [-ONE_SIXTH, 0.5, -0.5, ONE_SIXTH],
109
- [0.5, -1, 0.5, 0],
110
- [-0.5, 0, 0.5, 0],
111
- [ONE_SIXTH, 4 * ONE_SIXTH, ONE_SIXTH, 0]
112
- ],
113
- chunkCoefficients(parameters) {
114
- const coefficients = [];
115
- for (const chunk of chunkPointsBy(
116
- triplicateEndpoints ? [
117
- parameters[0],
118
- parameters[0],
119
- ...parameters,
120
- parameters[parameters.length - 1],
121
- parameters[parameters.length - 1]
122
- ] : parameters,
123
- 1
124
- )) {
125
- coefficients.push(pointsToCoefficients(this.matrix, chunk));
126
- }
127
- return coefficients;
128
- }
129
- });
130
- const splines = {
131
- basis,
132
- bezier,
133
- cardinal,
134
- catmullRom,
135
- hermite
136
- };
137
-
138
- export { basis, bezier, cardinal, catmullRom, hermite, pointsToCoefficients, splines };