@thi.ng/shader-ast-stdlib 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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2025-01-29T16:25:48Z
3
+ - **Last updated**: 2025-02-19T20:59:58Z
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.
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  [![Mastodon Follow](https://img.shields.io/mastodon/follow/109331703950160316?domain=https%3A%2F%2Fmastodon.thi.ng&style=social)](https://mastodon.thi.ng/@toxi)
8
8
 
9
9
  > [!NOTE]
10
- > This is one of 201 standalone projects, maintained as part
10
+ > This is one of 202 standalone projects, maintained as part
11
11
  > of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
12
12
  > and anti-framework.
13
13
  >
@@ -2,12 +2,13 @@ import { type FloatTerm, type Vec3Term } from "@thi.ng/shader-ast";
2
2
  /**
3
3
  * Inline function. Computes the unclamped cosine-based color gradient value:
4
4
  * `a+b*cos(2π*(c*t+d))`, where `a`..`d` are the gradient coefficients and `t`
5
- * the gradient position in the [0,1] interval.
5
+ * the gradient position in the `[0,1]` interval.
6
6
  *
7
7
  * @remarks
8
8
  * Based on technique by Inigo Quilez
9
9
  *
10
10
  * References:
11
+ *
11
12
  * - https://iquilezles.org/articles/palettes/
12
13
  * - https://github.com/thi-ng/umbrella/tree/develop/packages/color#cosine-gradients
13
14
  *
package/color/levels.d.ts CHANGED
@@ -17,7 +17,7 @@ export declare const midLevelGamma: import("@thi.ng/shader-ast").TaggedFn1<"floa
17
17
  export declare const midLevelGammaRGB: (mid: Vec3Term) => import("@thi.ng/shader-ast").Lit<"vec3">;
18
18
  /**
19
19
  * Applies level remapping from `input` to `output` (each given as
20
- * `vec2(min,max)`) with `gamma` correction. Results will be clamped to [0..1]
20
+ * `vec2(min,max)`) with `gamma` correction. Results will be clamped to `[0,1]`
21
21
  * range.
22
22
  */
23
23
  export declare const levelAdjustGamma: import("@thi.ng/shader-ast").TaggedFn4<"float", "float", "vec2", "vec2", "float">;
@@ -6,7 +6,7 @@ import type { FloatTerm, Vec4Sym } from "@thi.ng/shader-ast";
6
6
  * optimized AST function which accepts 2 RGBA colors (vec4) and returns blended
7
7
  * & clamped result (also a vec4).
8
8
  *
9
- * @remark
9
+ * @remarks
10
10
  * All built-in PD operators are defined via this HOF. The two given coefficient
11
11
  * functions are used to extract blending coefficients for src/dest colors and
12
12
  * are called with the alpha components of both colors.
@@ -1,7 +1,7 @@
1
1
  import type { FloatTerm, Term, Type } from "@thi.ng/shader-ast";
2
2
  /**
3
3
  * Utility function to create an n-ary conditional based on given float value
4
- * `x` in [0,1] range and any number of branch terms (at least 1). Returns a
4
+ * `x` in `[0,1]` range and any number of branch terms (at least 1). Returns a
5
5
  * nested ternary expression.
6
6
  *
7
7
  * @remarks
package/fog/exp.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Computes exponential fog factor [0..1], based on given fully
3
- * saturated fog distance and density.
2
+ * Computes exponential fog factor `[0,1]`, based on given fully saturated fog
3
+ * distance and density.
4
4
  *
5
5
  * @param dist - float
6
6
  * @param density - float
package/fog/exp2.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Similar to {@link fogExp}. Computes exponential fog factor [0..1], based on
2
+ * Similar to {@link fogExp}. Computes exponential fog factor `[0,1]`, based on
3
3
  * given fully saturated fog distance and density. Uses
4
- * [`exp2()`](https://docs.thi.ng/umbrella/shader-ast/functions/exp2.html)
4
+ * [`exp2`](https://docs.thi.ng/umbrella/shader-ast/functions/exp2.html)
5
5
  * internally.
6
6
  *
7
7
  * @param dist - float
package/fog/linear.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  /**
2
- * Computes linear fog factor [0..1], based on given fog min/max
3
- * distances.
2
+ * Computes linear fog factor `[0,1]`, based on given fog min/max distances.
4
3
  *
5
4
  * @param dist - float
6
5
  * @param start - float
@@ -1,17 +1,16 @@
1
1
  import type { Fn } from "@thi.ng/api";
2
2
  import type { FloatTerm, Prim, Term } from "@thi.ng/shader-ast";
3
3
  /**
4
- * Higher order function. Takes an AST type ID, a single-arg scalar
5
- * function `fn`, number of octaves (default: 4) and an optional
6
- * function name. Returns a new function which computes the summed value
7
- * of `fn` over the given number octaves and accepts 3 args:
4
+ * Higher order function. Takes an AST type ID, a single-arg scalar function
5
+ * `fn`, number of octaves (default: 4) and an optional function name. Returns a
6
+ * new function which computes the summed value of `fn` over the given number
7
+ * octaves and accepts 3 args:
8
8
  *
9
9
  * - position (float)
10
10
  * - octave shift (float)
11
11
  * - octave decay (usually 0.5)
12
12
  *
13
- * For each octave `i` [0..oct), the function is (in principle)
14
- * evaluated as:
13
+ * For each octave `i` `[0,oct)`, the function is (in principle) evaluated as:
15
14
  *
16
15
  * n += decay / exp2(i) * fn(pos * exp2(i) + i * shift)
17
16
  *
package/math/fit.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { Prim, PrimTerm, Term, TermType } from "@thi.ng/shader-ast";
2
2
  /**
3
- * Returns normalized value of `x` WRT to interval [a,b]. Returns 0, if
4
- * `a` equals `b`.
3
+ * Returns normalized value of `x` WRT to interval `[a,b]`. Returns 0, if `a`
4
+ * equals `b`.
5
5
  *
6
6
  * @param x -
7
7
  * @param a -
@@ -10,7 +10,7 @@ import type { Prim, PrimTerm, Term, TermType } from "@thi.ng/shader-ast";
10
10
  export declare const fitNorm1: import("@thi.ng/shader-ast").TaggedFn3<"float", "float", "float", "float">;
11
11
  /**
12
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]
13
+ * `a == b`. Scales value `x` from closed interval `[a,b]` to closed `[0,1]`
14
14
  * interval. No clamping performed.
15
15
  *
16
16
  * @param x
@@ -19,7 +19,7 @@ export declare const fitNorm1: import("@thi.ng/shader-ast").TaggedFn3<"float", "
19
19
  */
20
20
  export declare const fitNorm: <T extends Prim>(x: Term<T>, a: Term<T>, b: Term<T>) => import("@thi.ng/shader-ast").Op2<T>;
21
21
  /**
22
- * Fits value `x` from closed interval [a,b] to closed interval [c,d]. No
22
+ * Fits value `x` from closed interval `[a,b]` to closed interval `[c,d]`. No
23
23
  * clamping performed.
24
24
  *
25
25
  * @param x -
@@ -30,7 +30,7 @@ export declare const fitNorm: <T extends Prim>(x: Term<T>, a: Term<T>, b: Term<T
30
30
  */
31
31
  export declare const fit: <T extends Prim>(x: Term<T>, a: Term<T>, b: Term<T>, c: Term<T>, d: Term<T>) => import("@thi.ng/shader-ast").FnCall<T>;
32
32
  /**
33
- * Same as {@link fit}, but first clamps `x` to closed [a,b] interval.
33
+ * Same as {@link fit}, but first clamps `x` to closed `[a,b]` interval.
34
34
  *
35
35
  * @param x -
36
36
  * @param a -
@@ -40,8 +40,8 @@ export declare const fit: <T extends Prim>(x: Term<T>, a: Term<T>, b: Term<T>, c
40
40
  */
41
41
  export declare const fitClamped: <T extends Prim>(x: Term<T>, a: Term<T>, b: Term<T>, c: Term<T>, d: Term<T>) => import("@thi.ng/shader-ast").FnCall<T>;
42
42
  /**
43
- * Inline function. Fits value `a` in [0..1] interval to new interval
44
- * [b..c]. No clamping performed. Same as `mix(b, c, a)`
43
+ * Inline function. Fits value `a` in `[0,1]` interval to new interval `[b,c]`.
44
+ * No clamping performed. Same as `mix(b, c, a)`
45
45
  *
46
46
  * @param a -
47
47
  * @param b -
@@ -49,15 +49,15 @@ export declare const fitClamped: <T extends Prim>(x: Term<T>, a: Term<T>, b: Ter
49
49
  */
50
50
  export declare const fit01: <T extends Prim>(a: Term<T>, b: Term<T>, c: Term<T>) => Term<T>;
51
51
  /**
52
- * Inline function. Fits value `x` in [-1..+1] interval to [0..1]
53
- * interval. No clamping performed.
52
+ * Inline function. Fits value `x` in `[-1,1]` interval to `[0,1]` interval. No
53
+ * clamping performed.
54
54
  *
55
55
  * @param x -
56
56
  */
57
57
  export declare const fit1101: <T extends PrimTerm>(x: T) => Term<TermType<T>>;
58
58
  /**
59
- * Inline function. Fits value `x` in [0..1] interval to [-1..+1]
60
- * interval. No clamping performed.
59
+ * Inline function. Fits value `x` in `[0,1]` interval to `[-1,1]` interval. No
60
+ * clamping performed.
61
61
  *
62
62
  * @param x -
63
63
  */
@@ -8,8 +8,10 @@ export declare const trunc: import("@thi.ng/shader-ast").TaggedFn1<"float", "flo
8
8
  */
9
9
  export declare const modulo: import("@thi.ng/shader-ast").TaggedFn2<"float", "float", "float">;
10
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.
11
+ * Same as
12
+ * [`foldback01`](https://docs.thi.ng/umbrella/math/functions/foldback01.html).
13
+ * Folds `x` into the closed `[0,1]` interval, using infinite internal
14
+ * reflection on either side of the interval.
13
15
  *
14
16
  * @param x
15
17
  */
@@ -1,14 +1,14 @@
1
1
  import type { Vec2Term } from "@thi.ng/shader-ast";
2
2
  /**
3
3
  * Inline function. Returns counter-clockwise perpendicular vector (assuming
4
- * Y-up). [-y, x]
4
+ * Y-up). `[-y,x]`
5
5
  *
6
6
  * @param v -
7
7
  */
8
8
  export declare const perpendicularCCW: (v: Vec2Term) => import("@thi.ng/shader-ast").Lit<"vec2">;
9
9
  /**
10
10
  * Inline function. Returns clockwise perpendicular vector (assuming Y-up).
11
- * [y,-x]
11
+ * `[y,-x]`
12
12
  *
13
13
  * @param v -
14
14
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Encodes a float value in [0,1) interval to a vec4 suitable for a 8bit/channel
3
- * render texture. Use {@link unpackFloat} for reverse op.
2
+ * Encodes a float value in `[0,1)` interval to a vec4 suitable for a
3
+ * 8bit/channel render texture. Use {@link unpackFloat} for reverse op.
4
4
  *
5
5
  * @remarks
6
6
  * Reference:
@@ -1,7 +1,7 @@
1
1
  import type { TaggedFn1 } from "@thi.ng/shader-ast";
2
2
  /**
3
3
  * Specialized version of {@link smootherStep}, assuming edges are 0/1
4
- * respectively and `x` is in [0..1]. No clamping performed.
4
+ * respectively and `x` is in `[0,1]`. No clamping performed.
5
5
  *
6
6
  * @param x
7
7
  */
@@ -2,10 +2,10 @@
2
2
  * IQ's parametric 2D voronoise. Depending on `u` and `v`, this function
3
3
  * produces 4 different noise types
4
4
  *
5
- * - cell noise (0,0)
6
- * - voronoi (1,0)
7
- * - perlin noise (0,1)
8
- * - voronoise (1,1)
5
+ * - cell noise `(0,0)`
6
+ * - voronoi `(1,0)`
7
+ * - perlin noise `(0,1)`
8
+ * - voronoise `(1,1)`
9
9
  *
10
10
  * http://www.iquilezles.org/www/articles/voronoise/voronoise.htm
11
11
  *
@@ -4,7 +4,7 @@ export declare const worleyDistManhattan: import("@thi.ng/shader-ast").TaggedFn2
4
4
  /**
5
5
  * Higher order function. Computes 2D Worley noise using provided distance
6
6
  * function. The returned function takes 2 args: position and jitter amount, the
7
- * latter in [0..1] interval. Returns noise components as vec2, with the x
7
+ * latter in `[0,1]` interval. Returns noise components as vec2, with the x
8
8
  * component containing the distance from closest simplex center and y the noise
9
9
  * value. The vector components can be used individually or combined (e.g.
10
10
  * `noise.y - noise.x`)...
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/shader-ast-stdlib",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "Function collection for modular GPGPU / shader programming with @thi.ng/shader-ast",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -42,12 +42,12 @@
42
42
  "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
43
43
  },
44
44
  "dependencies": {
45
- "@thi.ng/api": "^8.11.19",
46
- "@thi.ng/shader-ast": "^1.0.7"
45
+ "@thi.ng/api": "^8.11.21",
46
+ "@thi.ng/shader-ast": "^1.0.9"
47
47
  },
48
48
  "devDependencies": {
49
- "esbuild": "^0.24.2",
50
- "typedoc": "^0.27.6",
49
+ "esbuild": "^0.25.0",
50
+ "typedoc": "^0.27.7",
51
51
  "typescript": "^5.7.3"
52
52
  },
53
53
  "keywords": [
@@ -375,5 +375,5 @@
375
375
  ],
376
376
  "year": 2019
377
377
  },
378
- "gitHead": "dcc1dbfa6eae31ac65e12843987b94d4a7edc144\n"
378
+ "gitHead": "bee617702ac61d093465b967f8f973dc566faa6b\n"
379
379
  }
package/raymarch/ao.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import type { RaymarchScene } from "../api.js";
2
2
  /**
3
- * Higher order function returning an function to compute the Ambient
4
- * Occlusion term / shadow factor for given SDF scene function. The
5
- * returned function takes 2 arguments: surface pos and normal. It
6
- * returns a float in [0..1] interval (zero = fully occluded).
3
+ * Higher order function returning an function to compute the Ambient Occlusion
4
+ * term / shadow factor for given SDF scene function. The returned function
5
+ * takes 2 arguments: surface pos and normal. It returns a float in `[0,1]`
6
+ * interval (zero = fully occluded).
7
7
  *
8
8
  * @param scene -
9
9
  * @param numSamples -
package/screen/uv.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { Vec2Term, Vec4Term } from "@thi.ng/shader-ast";
2
2
  /**
3
- * Computes UV coord in [0..1] interval from given `fragCoord` and screen `res`.
3
+ * Computes UV coord in `[0,1]` interval from given `fragCoord` and screen
4
+ * `res`.
4
5
  *
5
6
  * @param fragCoord -
6
7
  * @param res -
@@ -8,7 +9,7 @@ import type { Vec2Term, Vec4Term } from "@thi.ng/shader-ast";
8
9
  export declare const fragUV: (fragCoord: Vec4Term, res: Vec2Term) => import("@thi.ng/shader-ast").Op2<"vec2">;
9
10
  /**
10
11
  * Takes `pos`, a screen coord (e.g. gl_FragCoord) and viewport resolution
11
- * `res`, returns aspect corrected uv, with uv.y in [-1..1] interval and uv.x
12
+ * `res`, returns aspect corrected uv, with uv.y in `[-1,1]` interval and uv.x
12
13
  * scaled by the aspect ratio `resx / resy`.
13
14
  *
14
15
  * @param fragCoord - vec2
@@ -17,7 +18,7 @@ export declare const fragUV: (fragCoord: Vec4Term, res: Vec2Term) => import("@th
17
18
  export declare const aspectCorrectedUV: import("@thi.ng/shader-ast").TaggedFn2<"vec2", "vec2", "vec2">;
18
19
  /**
19
20
  * Returns true if at least one coordinate of the given point is within the
20
- * `width` internal border region of UV rect ([0,0] .. [1,1]).
21
+ * `width` internal border region of UV rect (`[0,0]`..`[1,1]`).
21
22
  *
22
23
  * ```c
23
24
  * borderMask(vec2(0.91, 0.5), 0.1) // true
package/sdf/arc.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Returns signed distance from `p` to 2D circular arc with `aperture` (in
3
- * [0..π] interval), radius `ra` and `thickness`.
3
+ * `[0]` interval), radius `ra` and `thickness`.
4
4
  *
5
5
  * @remarks
6
6
  * Slightly modified version (easier to use aperture control) of original GLSL
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * @remarks
6
6
  * Ported from original GLSL impl by Inigo Quilez:
7
- * - https://iquilezles.org/articles/distfunctions2d/
7
+ * https://iquilezles.org/articles/distfunctions2d/
8
8
  *
9
9
  * @param p - vec2
10
10
  * @param size - vec2
package/sdf/cross.d.ts CHANGED
@@ -3,11 +3,12 @@
3
3
  * radius `r`.
4
4
  *
5
5
  * @remarks
6
+ *
6
7
  * - `size` consist of overall width/size (in x) and thickness (in y component)
7
8
  * - corner radius can also be negative
8
9
  *
9
10
  * Ported from original GLSL impl by Inigo Quilez:
10
- * - https://iquilezles.org/articles/distfunctions2d/
11
+ * https://iquilezles.org/articles/distfunctions2d/
11
12
  *
12
13
  * @param p -
13
14
  * @param size -
@@ -20,7 +21,7 @@ export declare const sdfCross2: import("@thi.ng/shader-ast").TaggedFn3<"vec2", "
20
21
  *
21
22
  * @remarks
22
23
  * Ported from original GLSL impl by Inigo Quilez:
23
- * - https://iquilezles.org/articles/distfunctions2d/
24
+ * https://iquilezles.org/articles/distfunctions2d/
24
25
  *
25
26
  * @param p -
26
27
  * @param size -
package/sdf/hex.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @remarks
5
5
  * Ported from original GLSL impl by Inigo Quilez:
6
- * - https://iquilezles.org/articles/distfunctions2d/
6
+ * https://iquilezles.org/articles/distfunctions2d/
7
7
  */
8
8
  export declare const sdfHexagon2: import("@thi.ng/shader-ast").TaggedFn2<"vec2", "float", "float">;
9
9
  //# sourceMappingURL=hex.d.ts.map
package/sdf/polygon.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * @remarks
6
6
  * Based on original GLSL impl by Inigo Quilez:
7
- * - https://iquilezles.org/articles/distfunctions2d/
7
+ * https://iquilezles.org/articles/distfunctions2d/
8
8
  *
9
9
  * @param N
10
10
  */
package/viz/function.d.ts CHANGED
@@ -24,14 +24,14 @@ export interface FnSampleOpts {
24
24
  area: boolean;
25
25
  /**
26
26
  * Min X position (in function domain). The function will only be evaluated
27
- * within the [min..max] domain.
27
+ * within the `[min,max]` domain.
28
28
  *
29
29
  * @defaultValue 0
30
30
  */
31
31
  min: number;
32
32
  /**
33
33
  * Max X position (in function domain). The function will only be evaluated
34
- * within the [min..max] domain.
34
+ * within the `[min,max]` domain.
35
35
  *
36
36
  * @defaultValue 1
37
37
  */