@mocanvas/editor · function

clamp

declare function clamp(n: number, min: number, max?: number): number

Clamp a value into a range. With no max, min is a floor only.

@example ``ts clamp(0, 1, 10) // 1 clamp(11, 1, 10) // 10 ``

mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.