@thi.ng/ramp 3.0.2 → 3.1.2
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 +11 -1
- package/README.md +5 -6
- package/api.d.ts +12 -1
- package/hermite.d.ts +8 -2
- package/hermite.js +2 -2
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/linear.d.ts +8 -2
- package/linear.js +2 -2
- package/package.json +12 -9
- package/vector.d.ts +6 -0
- package/vector.js +39 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2024-02-
|
|
3
|
+
- **Last updated**: 2024-02-22T11:59:16Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -9,6 +9,16 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
## [3.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/ramp@3.1.0) (2024-02-19)
|
|
13
|
+
|
|
14
|
+
#### 🚀 Features
|
|
15
|
+
|
|
16
|
+
- add minimal API presets for vector interpolations ([6dcb4b6](https://github.com/thi-ng/umbrella/commit/6dcb4b6))
|
|
17
|
+
- add VEC, VEC2/3/4 API presets
|
|
18
|
+
- add VecAPI interface
|
|
19
|
+
- update docs
|
|
20
|
+
- update pkg exports
|
|
21
|
+
|
|
12
22
|
# [3.0.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/ramp@3.0.0) (2024-02-12)
|
|
13
23
|
|
|
14
24
|
#### 🛑 Breaking changes
|
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
[](https://mastodon.thi.ng/@toxi)
|
|
19
19
|
|
|
20
20
|
> [!NOTE]
|
|
21
|
-
> This is one of
|
|
21
|
+
> This is one of 190 standalone projects, maintained as part
|
|
22
22
|
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
|
|
23
23
|
> and anti-framework.
|
|
24
24
|
>
|
|
@@ -75,7 +75,7 @@ For Node.js REPL:
|
|
|
75
75
|
const ramp = await import("@thi.ng/ramp");
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
-
Package sizes (brotli'd, pre-treeshake): ESM: 1.
|
|
78
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 1.84 KB
|
|
79
79
|
|
|
80
80
|
## Dependencies
|
|
81
81
|
|
|
@@ -131,8 +131,8 @@ for(let i = 0; i <= 10; i++) {
|
|
|
131
131
|
### nD vectors
|
|
132
132
|
|
|
133
133
|
```ts tangle:export/readme-vector.ts
|
|
134
|
-
import { HERMITE_V, ramp } from "@thi.ng/ramp";
|
|
135
|
-
import { FORMATTER
|
|
134
|
+
import { HERMITE_V, VEC3, ramp } from "@thi.ng/ramp";
|
|
135
|
+
import { FORMATTER } from "@thi.ng/vectors";
|
|
136
136
|
|
|
137
137
|
// use the generic `ramp()` factory function with a custom implementation
|
|
138
138
|
// see: https://docs.thi.ng/umbrella/ramp/interfaces/RampImpl.html
|
|
@@ -178,8 +178,7 @@ for (let i = 0; i <= 20; i++) {
|
|
|
178
178
|
### Nested objects
|
|
179
179
|
|
|
180
180
|
```ts tangle:export/readme-nested.ts
|
|
181
|
-
import { HERMITE_V, LINEAR_N, nested, ramp } from "@thi.ng/ramp";
|
|
182
|
-
import { VEC2 } from "@thi.ng/vectors";
|
|
181
|
+
import { HERMITE_V, LINEAR_N, VEC2, nested, ramp } from "@thi.ng/ramp";
|
|
183
182
|
|
|
184
183
|
const r = ramp(
|
|
185
184
|
nested({
|
package/api.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { Fn2 } from "@thi.ng/api";
|
|
1
|
+
import type { Fn, Fn2 } from "@thi.ng/api";
|
|
2
|
+
import type { Vec, VecOpN, VecOpVV, VecOpVVN } from "@thi.ng/vectors";
|
|
2
3
|
export type Frame<T> = [number, T];
|
|
3
4
|
export interface RampImpl<T> {
|
|
4
5
|
min: Fn2<T | null, T, T>;
|
|
@@ -70,4 +71,14 @@ export interface RampBounds<T> {
|
|
|
70
71
|
maxT: number;
|
|
71
72
|
}
|
|
72
73
|
export type RampDomain = (t: number, min: number, max: number) => number;
|
|
74
|
+
/**
|
|
75
|
+
* Operations required for vector interpolations.
|
|
76
|
+
*/
|
|
77
|
+
export interface VecAPI {
|
|
78
|
+
min: VecOpVV;
|
|
79
|
+
max: VecOpVV;
|
|
80
|
+
mixN: VecOpVVN;
|
|
81
|
+
setN: VecOpN;
|
|
82
|
+
vecOf: Fn<number, Vec>;
|
|
83
|
+
}
|
|
73
84
|
//# sourceMappingURL=api.d.ts.map
|
package/hermite.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Vec
|
|
2
|
-
import type { Frame, RampImpl, RampOpts } from "./api.js";
|
|
1
|
+
import type { Vec } from "@thi.ng/vectors";
|
|
2
|
+
import type { Frame, RampImpl, RampOpts, VecAPI } from "./api.js";
|
|
3
3
|
import { Ramp } from "./ramp.js";
|
|
4
4
|
/**
|
|
5
5
|
* Syntax sugar for creating a numeric {@link Ramp} using the {@link HERMITE_N}
|
|
@@ -21,5 +21,11 @@ import { Ramp } from "./ramp.js";
|
|
|
21
21
|
*/
|
|
22
22
|
export declare const hermite: (stops: Frame<number>[], opts?: Partial<RampOpts>) => Ramp<number>;
|
|
23
23
|
export declare const HERMITE_N: RampImpl<number>;
|
|
24
|
+
/**
|
|
25
|
+
* Vector version of {@link HERMITE_N}. Use with any of the supplied vector APIs:
|
|
26
|
+
* {@link VEC} (arbitrary size), {@link VEC2}, {@link VEC3} or {@link VEC4}.
|
|
27
|
+
*
|
|
28
|
+
* @param vec
|
|
29
|
+
*/
|
|
24
30
|
export declare const HERMITE_V: <T extends Vec>(vec: VecAPI) => RampImpl<T>;
|
|
25
31
|
//# sourceMappingURL=hermite.d.ts.map
|
package/hermite.js
CHANGED
|
@@ -18,8 +18,8 @@ const HERMITE_N = {
|
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
const HERMITE_V = (vec) => ({
|
|
21
|
-
min: (acc, x) => vec.min(acc, acc || vec.
|
|
22
|
-
max: (acc, x) => vec.max(acc, acc || vec.
|
|
21
|
+
min: (acc, x) => vec.min(acc, acc || vec.vecOf(Infinity), x),
|
|
22
|
+
max: (acc, x) => vec.max(acc, acc || vec.vecOf(-Infinity), x),
|
|
23
23
|
at: (stops, i, t) => {
|
|
24
24
|
const n = stops.length - 1;
|
|
25
25
|
const [, a] = stops[Math.max(i - 1, 0)];
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
package/linear.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Vec
|
|
2
|
-
import type { Frame, RampImpl, RampOpts } from "./api.js";
|
|
1
|
+
import type { Vec } from "@thi.ng/vectors";
|
|
2
|
+
import type { Frame, RampImpl, RampOpts, VecAPI } from "./api.js";
|
|
3
3
|
import { Ramp } from "./ramp.js";
|
|
4
4
|
/**
|
|
5
5
|
* Syntax sugar for creating a numeric {@link Ramp} using the {@link LINEAR_N}
|
|
@@ -14,5 +14,11 @@ import { Ramp } from "./ramp.js";
|
|
|
14
14
|
*/
|
|
15
15
|
export declare const linear: (stops: Frame<number>[], opts?: Partial<RampOpts>) => Ramp<number>;
|
|
16
16
|
export declare const LINEAR_N: RampImpl<number>;
|
|
17
|
+
/**
|
|
18
|
+
* Vector version of {@link LINEAR_N}. Use with any of the supplied vector APIs:
|
|
19
|
+
* {@link VEC} (arbitrary size), {@link VEC2}, {@link VEC3} or {@link VEC4}.
|
|
20
|
+
*
|
|
21
|
+
* @param vec
|
|
22
|
+
*/
|
|
17
23
|
export declare const LINEAR_V: <T extends Vec>(vec: VecAPI) => RampImpl<T>;
|
|
18
24
|
//# sourceMappingURL=linear.d.ts.map
|
package/linear.js
CHANGED
|
@@ -11,8 +11,8 @@ const LINEAR_N = {
|
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
13
|
const LINEAR_V = (vec) => ({
|
|
14
|
-
min: (acc, x) => vec.min(acc, acc || vec.
|
|
15
|
-
max: (acc, x) => vec.max(acc, acc || vec.
|
|
14
|
+
min: (acc, x) => vec.min(acc, acc || vec.vecOf(Infinity), x),
|
|
15
|
+
max: (acc, x) => vec.max(acc, acc || vec.vecOf(-Infinity), x),
|
|
16
16
|
at: (stops, i, t) => {
|
|
17
17
|
const a = stops[i];
|
|
18
18
|
const b = stops[i + 1];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/ramp",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.2",
|
|
4
4
|
"description": "Extensible keyframe interpolation/tweening of arbitrary, nested types",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
"test": "bun test"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@thi.ng/api": "^8.9.
|
|
39
|
-
"@thi.ng/arrays": "^2.
|
|
40
|
-
"@thi.ng/compare": "^2.2.
|
|
41
|
-
"@thi.ng/errors": "^2.4.
|
|
42
|
-
"@thi.ng/math": "^5.10.
|
|
43
|
-
"@thi.ng/transducers": "^8.9.
|
|
44
|
-
"@thi.ng/vectors": "^7.10.
|
|
38
|
+
"@thi.ng/api": "^8.9.25",
|
|
39
|
+
"@thi.ng/arrays": "^2.8.2",
|
|
40
|
+
"@thi.ng/compare": "^2.2.21",
|
|
41
|
+
"@thi.ng/errors": "^2.4.18",
|
|
42
|
+
"@thi.ng/math": "^5.10.2",
|
|
43
|
+
"@thi.ng/transducers": "^8.9.5",
|
|
44
|
+
"@thi.ng/vectors": "^7.10.10"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@microsoft/api-extractor": "^7.40.1",
|
|
@@ -109,10 +109,13 @@
|
|
|
109
109
|
},
|
|
110
110
|
"./ramp": {
|
|
111
111
|
"default": "./ramp.js"
|
|
112
|
+
},
|
|
113
|
+
"./vector": {
|
|
114
|
+
"default": "./vector.js"
|
|
112
115
|
}
|
|
113
116
|
},
|
|
114
117
|
"thi.ng": {
|
|
115
118
|
"year": 2019
|
|
116
119
|
},
|
|
117
|
-
"gitHead": "
|
|
120
|
+
"gitHead": "4513a1c703bdbf0f0867f03e547e47692e415fac\n"
|
|
118
121
|
}
|
package/vector.d.ts
ADDED
package/vector.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { max, max2, max3, max4 } from "@thi.ng/vectors/max";
|
|
2
|
+
import { min, min2, min3, min4 } from "@thi.ng/vectors/min";
|
|
3
|
+
import { mixN, mixN2, mixN3, mixN4 } from "@thi.ng/vectors/mixn";
|
|
4
|
+
import { setN, setN2, setN3, setN4 } from "@thi.ng/vectors/setn";
|
|
5
|
+
import { vecOf } from "@thi.ng/vectors/vec-of";
|
|
6
|
+
const VEC = (size) => ({
|
|
7
|
+
min,
|
|
8
|
+
max,
|
|
9
|
+
mixN,
|
|
10
|
+
vecOf: (n) => vecOf(size, n),
|
|
11
|
+
setN
|
|
12
|
+
});
|
|
13
|
+
const VEC2 = {
|
|
14
|
+
min: min2,
|
|
15
|
+
max: max2,
|
|
16
|
+
mixN: mixN2,
|
|
17
|
+
setN: setN2,
|
|
18
|
+
vecOf: (x) => vecOf(2, x)
|
|
19
|
+
};
|
|
20
|
+
const VEC3 = {
|
|
21
|
+
min: min3,
|
|
22
|
+
max: max3,
|
|
23
|
+
mixN: mixN3,
|
|
24
|
+
setN: setN3,
|
|
25
|
+
vecOf: (x) => vecOf(3, x)
|
|
26
|
+
};
|
|
27
|
+
const VEC4 = {
|
|
28
|
+
min: min4,
|
|
29
|
+
max: max4,
|
|
30
|
+
mixN: mixN4,
|
|
31
|
+
setN: setN4,
|
|
32
|
+
vecOf: (x) => vecOf(4, x)
|
|
33
|
+
};
|
|
34
|
+
export {
|
|
35
|
+
VEC,
|
|
36
|
+
VEC2,
|
|
37
|
+
VEC3,
|
|
38
|
+
VEC4
|
|
39
|
+
};
|