sub()
Function in Builtins
a - b as a free function.
import { sub } from 'typeshade'
The signature, the description and the examples come from the compiler's own source at commit 26de7be8.
Syntax
function sub<E extends string, N extends number>( a: ReadonlyNode<E>, b: ReadonlyNode<`vec${N}<${E}>`>,): Node<`vec${N}<${E}>`>;function sub<K extends string>(a: ReadonlyNode<K>, b: ArithArg<K>): Node<K>;function sub<K extends string>(a: number, b: ReadonlyNode<K>): Node<K>;Parameters
aReadonlyNode<E>bReadonlyNode<`vec${N}<${E}>`>
Return value
Node<`vec${N}<${E}>`>
Exceptions
TypeErrorboth operands are plain numbers.
Description
sub(1, smoothstep(e0, e1, x)) is the inverted-ramp idiom the
method form has to spell f32(1).sub(...); both emit (1.0 - smoothstep(...)).
Whichever operand is a node types the other. Two bare numbers are rejected.
Examples
Example
import { fn, sub, smoothstep, f32T } from 'typeshade'
const rim = fn('rim', { d: f32T }, ({ d }) => sub(1, smoothstep(0, 1, d)))In the guide
See also
Source
src/core/ir/node.ts, line 1195, at commit 26de7be8