clamp()
함수, 내장 함수 분류
clamp(x, lo, hi): restricts x to [lo, hi], component-wise.
import { clamp } from 'typeshade'
시그니처, 설명, 예제는 커밋 c66579bf의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.
구문
const clamp: <K extends FloatKey | IntKey>( x: ReadonlyNode<K>, lo: NoInfer<ArithArg<K>>, hi: NoInfer<ArithArg<K>>,) => Node<K>매개변수
xReadonlyNode<K>loNoInfer<ArithArg<K>>hiNoInfer<ArithArg<K>>
반환값
Node<K>
설명
lo and hi may be
scalar broadcasts against a vector x. It is the standard guard before asin and
acos, whose domain is [-1, 1], keeping float rounding from pushing an in-range
value a hair past its bound.
예제
예제
import { fn, clamp, f32T } from 'typeshade'
const norm = fn('norm', { x: f32T }, ({ x }) => clamp(x, 0, 1))대상별 지원
| 대상 | 지원 | 비고 |
|---|---|---|
| WGSL (WebGPU) | 지원 |
|
| GLSL ES 3.00 (WebGL2) | 지원 |
|
| CPU 오라클 | 지원 | Evaluated in f64 by the oracle. |
관련 가이드
함께 보기
소스
src/core/ir/node.ts, 1711행, 커밋 c66579bf 기준