@thi.ng/shader-ast-stdlib 0.15.0 → 0.16.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.
- package/CHANGELOG.md +7 -1
- package/README.md +1 -1
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/math/fit.d.ts +11 -10
- package/math/fit.js +11 -10
- package/math/interval.d.ts +17 -0
- package/math/interval.js +33 -0
- package/package.json +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2023-10-
|
|
3
|
+
- **Last updated**: 2023-10-27T16:56:24Z
|
|
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,12 @@ 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
|
+
## [0.16.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/shader-ast-stdlib@0.16.0) (2023-10-27)
|
|
13
|
+
|
|
14
|
+
#### 🚀 Features
|
|
15
|
+
|
|
16
|
+
- add trunc(), modulo(), foldback01() ([d3ab3e6](https://github.com/thi-ng/umbrella/commit/d3ab3e6))
|
|
17
|
+
|
|
12
18
|
## [0.15.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/shader-ast-stdlib@0.15.0) (2023-10-25)
|
|
13
19
|
|
|
14
20
|
#### 🚀 Features
|
package/README.md
CHANGED
package/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export * from "./math/cross2.js";
|
|
|
18
18
|
export * from "./math/dist-chebyshev.js";
|
|
19
19
|
export * from "./math/dist-manhattan.js";
|
|
20
20
|
export * from "./math/fit.js";
|
|
21
|
+
export * from "./math/interval.js";
|
|
21
22
|
export * from "./math/magsq.js";
|
|
22
23
|
export * from "./math/maxcomp.js";
|
|
23
24
|
export * from "./math/mincomp.js";
|
package/index.js
CHANGED
|
@@ -18,6 +18,7 @@ export * from "./math/cross2.js";
|
|
|
18
18
|
export * from "./math/dist-chebyshev.js";
|
|
19
19
|
export * from "./math/dist-manhattan.js";
|
|
20
20
|
export * from "./math/fit.js";
|
|
21
|
+
export * from "./math/interval.js";
|
|
21
22
|
export * from "./math/magsq.js";
|
|
22
23
|
export * from "./math/maxcomp.js";
|
|
23
24
|
export * from "./math/mincomp.js";
|
package/math/fit.d.ts
CHANGED
|
@@ -8,6 +8,17 @@ import type { PrimTerm, Term, TermType } from "@thi.ng/shader-ast";
|
|
|
8
8
|
* @param b -
|
|
9
9
|
*/
|
|
10
10
|
export declare const fitNorm1: import("@thi.ng/shader-ast").TaggedFn3<"float", "float", "float", "float">;
|
|
11
|
+
/**
|
|
12
|
+
* Similar to {@link fitNorm1} but also for vector types and without checking if
|
|
13
|
+
* `a == b`. Scales value `x` from closed interval [a,b] to closed [0,1]
|
|
14
|
+
* interval. No clamping performed.
|
|
15
|
+
*
|
|
16
|
+
* @param x
|
|
17
|
+
* @param a
|
|
18
|
+
* @param b
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
export declare const fitNorm: <T extends PrimTerm>(x: T, a: T, b: T) => Term<TermType<T>>;
|
|
11
22
|
/**
|
|
12
23
|
* Fits value `x` from closed interval [a,b] to closed interval [c,d]. No
|
|
13
24
|
* clamping performed.
|
|
@@ -19,16 +30,6 @@ export declare const fitNorm1: import("@thi.ng/shader-ast").TaggedFn3<"float", "
|
|
|
19
30
|
* @param d -
|
|
20
31
|
*/
|
|
21
32
|
export declare const fit: <T extends PrimTerm>(x: T, a: T, b: T, c: T, d: T) => Term<TermType<T>>;
|
|
22
|
-
/**
|
|
23
|
-
* Scales value `x` from closed interval [a,b] to closed [0,1] interval. No
|
|
24
|
-
* clamping performed.
|
|
25
|
-
*
|
|
26
|
-
* @param x
|
|
27
|
-
* @param a
|
|
28
|
-
* @param b
|
|
29
|
-
* @returns
|
|
30
|
-
*/
|
|
31
|
-
export declare const fitNorm: <T extends PrimTerm>(x: T, a: T, b: T) => Term<TermType<T>>;
|
|
32
33
|
/**
|
|
33
34
|
* Same as {@link fit}, but first clamps `x` to closed [a,b] interval.
|
|
34
35
|
*
|
package/math/fit.js
CHANGED
|
@@ -16,6 +16,17 @@ import { clamp01 } from "./clamp.js";
|
|
|
16
16
|
export const fitNorm1 = defn(F, "fitNorm1", [F, F, F], (x, a, b) => [
|
|
17
17
|
ret(ternary(neq(a, b), div(sub(x, a), sub(b, a)), FLOAT0)),
|
|
18
18
|
]);
|
|
19
|
+
/**
|
|
20
|
+
* Similar to {@link fitNorm1} but also for vector types and without checking if
|
|
21
|
+
* `a == b`. Scales value `x` from closed interval [a,b] to closed [0,1]
|
|
22
|
+
* interval. No clamping performed.
|
|
23
|
+
*
|
|
24
|
+
* @param x
|
|
25
|
+
* @param a
|
|
26
|
+
* @param b
|
|
27
|
+
* @returns
|
|
28
|
+
*/
|
|
29
|
+
export const fitNorm = (x, a, b) => div(sub(x, a), sub(b, a));
|
|
19
30
|
/**
|
|
20
31
|
* Fits value `x` from closed interval [a,b] to closed interval [c,d]. No
|
|
21
32
|
* clamping performed.
|
|
@@ -27,16 +38,6 @@ export const fitNorm1 = defn(F, "fitNorm1", [F, F, F], (x, a, b) => [
|
|
|
27
38
|
* @param d -
|
|
28
39
|
*/
|
|
29
40
|
export const fit = (x, a, b, c, d) => mix(c, d, fitNorm(x, a, b));
|
|
30
|
-
/**
|
|
31
|
-
* Scales value `x` from closed interval [a,b] to closed [0,1] interval. No
|
|
32
|
-
* clamping performed.
|
|
33
|
-
*
|
|
34
|
-
* @param x
|
|
35
|
-
* @param a
|
|
36
|
-
* @param b
|
|
37
|
-
* @returns
|
|
38
|
-
*/
|
|
39
|
-
export const fitNorm = (x, a, b) => div(sub(x, a), sub(b, a));
|
|
40
41
|
/**
|
|
41
42
|
* Same as {@link fit}, but first clamps `x` to closed [a,b] interval.
|
|
42
43
|
*
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GLSL 100 trunc() polyfill.
|
|
3
|
+
*/
|
|
4
|
+
export declare const trunc: import("@thi.ng/shader-ast").TaggedFn1<"float", "float">;
|
|
5
|
+
/**
|
|
6
|
+
* Returns `x - y * trunc(x / y)`, i.e. essentially the same as JS `%` operator.
|
|
7
|
+
* Result will always have the sign of `x`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const modulo: import("@thi.ng/shader-ast").TaggedFn2<"float", "float", "float">;
|
|
10
|
+
/**
|
|
11
|
+
* Same as thi.ng/math foldback01(). Folds `x` into the closed [0..1] interval,
|
|
12
|
+
* using infinite internal reflection on either side of the interval.
|
|
13
|
+
*
|
|
14
|
+
* @param x
|
|
15
|
+
*/
|
|
16
|
+
export declare const foldback01: import("@thi.ng/shader-ast").TaggedFn1<"float", "float">;
|
|
17
|
+
//# sourceMappingURL=interval.d.ts.map
|
package/math/interval.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { F } from "@thi.ng/shader-ast/api/types";
|
|
2
|
+
import { ternary } from "@thi.ng/shader-ast/ast/controlflow";
|
|
3
|
+
import { defn, ret } from "@thi.ng/shader-ast/ast/function";
|
|
4
|
+
import { FLOAT0, FLOAT1, FLOAT2 } from "@thi.ng/shader-ast/ast/lit";
|
|
5
|
+
import { div, lt, mul, sub } from "@thi.ng/shader-ast/ast/ops";
|
|
6
|
+
import { sym } from "@thi.ng/shader-ast/ast/sym";
|
|
7
|
+
import { abs, ceil, floor, mix, mod, step, } from "@thi.ng/shader-ast/builtin/math";
|
|
8
|
+
/**
|
|
9
|
+
* GLSL 100 trunc() polyfill.
|
|
10
|
+
*/
|
|
11
|
+
export const trunc = defn(F, null, [F], (x) => [
|
|
12
|
+
ret(ternary(lt(x, FLOAT0), ceil(x), floor(x))),
|
|
13
|
+
]);
|
|
14
|
+
/**
|
|
15
|
+
* Returns `x - y * trunc(x / y)`, i.e. essentially the same as JS `%` operator.
|
|
16
|
+
* Result will always have the sign of `x`.
|
|
17
|
+
*/
|
|
18
|
+
export const modulo = defn(F, null, [F, F], (x, y) => [
|
|
19
|
+
ret(sub(x, mul(y, trunc(div(x, y))))),
|
|
20
|
+
]);
|
|
21
|
+
/**
|
|
22
|
+
* Same as thi.ng/math foldback01(). Folds `x` into the closed [0..1] interval,
|
|
23
|
+
* using infinite internal reflection on either side of the interval.
|
|
24
|
+
*
|
|
25
|
+
* @param x
|
|
26
|
+
*/
|
|
27
|
+
export const foldback01 = defn(F, null, [F], (x) => {
|
|
28
|
+
let y;
|
|
29
|
+
return [
|
|
30
|
+
(y = sym(mod(abs(x), FLOAT2))),
|
|
31
|
+
ret(mix(y, sub(FLOAT2, y), step(FLOAT1, y))),
|
|
32
|
+
];
|
|
33
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/shader-ast-stdlib",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "Function collection for modular GPGPU / shader programming with @thi.ng/shader-ast",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@thi.ng/api": "^8.9.6",
|
|
41
|
-
"@thi.ng/shader-ast": "^0.12.
|
|
41
|
+
"@thi.ng/shader-ast": "^0.12.76"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@microsoft/api-extractor": "^7.38.0",
|
|
@@ -162,6 +162,9 @@
|
|
|
162
162
|
"./math/fit": {
|
|
163
163
|
"default": "./math/fit.js"
|
|
164
164
|
},
|
|
165
|
+
"./math/interval": {
|
|
166
|
+
"default": "./math/interval.js"
|
|
167
|
+
},
|
|
165
168
|
"./math/magsq": {
|
|
166
169
|
"default": "./math/magsq.js"
|
|
167
170
|
},
|
|
@@ -349,5 +352,5 @@
|
|
|
349
352
|
],
|
|
350
353
|
"year": 2019
|
|
351
354
|
},
|
|
352
|
-
"gitHead": "
|
|
355
|
+
"gitHead": "502e8fa937677ff7bc4fbd0906d8c8b4b0b471e5\n"
|
|
353
356
|
}
|