Clamp a value into a range.

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

Example

const A = clamp(0, 1, 10) // 1
const B = clamp(11, 1, 10) // 10
const C = clamp(5, 1, 10) // 5

Parameters

NameDescription

n

number

The number to clamp.

min

number

The minimum value.

max

number

The maximum value.

Returns

number
Prev
centerOfCircleFromThreePoints
Next
clampRadians