min()
Function in Builtins
min(a, b): component-wise minimum.
import { min } from 'typeshade'
The signature, the description and the examples come from the compiler's own source at commit 26de7be8.
Syntax
const min: <K extends FloatKey | Float64Key | IntKey>( a: ReadonlyNode<K>, b: NoInfer<ArithArg<K>>,) => Node<K>Parameters
aReadonlyNode<K>bNoInfer<ArithArg<K>>
Return value
Node<K>
Description
b may be a scalar broadcast against a vector a,
the same rule as the arithmetic methods, so min(color, 1) caps every channel against one
literal without unrolling per component.
Examples
Example
import { fn, min, f32T } from 'typeshade'
const capped = fn('capped', { x: f32T }, ({ x }) => min(x, 1))Targets
| Target | Support | Notes |
|---|---|---|
| WGSL (WebGPU) | Supported |
|
| GLSL ES 3.00 (WebGL2) | Supported |
|
| CPU oracle | Supported | Evaluated in f64 by the oracle. |
In the guide
Source
src/core/ir/node.ts, line 1633, at commit 26de7be8