Clamps a number between a minimum and maximum value.
Essential companion for math utilities.
Ensures that a value does not exceed specified bounds, which is crucial for things like UI dimensions, game mechanics, or any scenario where you want to enforce limits.
Parameters
val: number
The number to clamp.
min: number
The minimum allowed value.
max: number
The maximum allowed value.
Returns number
The clamped value, guaranteed to be between min and max.
Clamps a number between a minimum and maximum value. Essential companion for math utilities. Ensures that a value does not exceed specified bounds, which is crucial for things like UI dimensions, game mechanics, or any scenario where you want to enforce limits.