@thi.ng/ramp 3.0.2 → 3.1.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2024-02-12T16:28:41Z
3
+ - **Last updated**: 2024-02-19T16:07:07Z
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
@@ -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.67 KB
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, VEC3 } from "@thi.ng/vectors";
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, VecAPI } from "@thi.ng/vectors";
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.setN([], Infinity), x),
22
- max: (acc, x) => vec.max(acc, acc || vec.setN([], -Infinity), x),
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
@@ -5,4 +5,5 @@ export * from "./hermite.js";
5
5
  export * from "./linear.js";
6
6
  export * from "./nested.js";
7
7
  export * from "./ramp.js";
8
+ export * from "./vector.js";
8
9
  //# sourceMappingURL=index.d.ts.map
package/index.js CHANGED
@@ -5,3 +5,4 @@ export * from "./hermite.js";
5
5
  export * from "./linear.js";
6
6
  export * from "./nested.js";
7
7
  export * from "./ramp.js";
8
+ export * from "./vector.js";
package/linear.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { Vec, VecAPI } from "@thi.ng/vectors";
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.setN([], Infinity), x),
15
- max: (acc, x) => vec.max(acc, acc || vec.setN([], -Infinity), x),
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.0.2",
3
+ "version": "3.1.1",
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.23",
39
- "@thi.ng/arrays": "^2.7.20",
40
- "@thi.ng/compare": "^2.2.19",
41
- "@thi.ng/errors": "^2.4.16",
42
- "@thi.ng/math": "^5.10.0",
43
- "@thi.ng/transducers": "^8.9.2",
44
- "@thi.ng/vectors": "^7.10.7"
38
+ "@thi.ng/api": "^8.9.24",
39
+ "@thi.ng/arrays": "^2.8.1",
40
+ "@thi.ng/compare": "^2.2.20",
41
+ "@thi.ng/errors": "^2.4.17",
42
+ "@thi.ng/math": "^5.10.1",
43
+ "@thi.ng/transducers": "^8.9.4",
44
+ "@thi.ng/vectors": "^7.10.9"
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": "25ee18f7db6d03f0b76787267ab071d16df94888\n"
120
+ "gitHead": "2724c87ca41810f2112f9d8c3d6b90dfaeea876b\n"
118
121
  }
package/vector.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import type { VecAPI } from "./api.js";
2
+ export declare const VEC: (size: number) => VecAPI;
3
+ export declare const VEC2: VecAPI;
4
+ export declare const VEC3: VecAPI;
5
+ export declare const VEC4: VecAPI;
6
+ //# sourceMappingURL=vector.d.ts.map
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
+ };