Maps a value to a relative range and clamps the result within another range.
This function first calculates the relative progress of value within scope
using the scoped function. Then, it clamps the resulting progress to clamp
using the clamp function.
Parameters
value: number
The input value to be mapped and clamped.
Optionalscope: number[] = ...
The range (start and end) within which to map the input value.
Optionalclamp: number[] = ...
The range (start and end) within which to clamp the mapped value.
Returns number
The resulting value after mapping and clamping.
Example
clampScope(0.36, [0.35, 1]); // => 0.015384 (relative progress of 0.36 within [0.35, 1], clamped to [0, 1])
clampScope(0.36, [0.35, 1], [0.1, 1]); // => 0.1 (relative progress of 0.36 within [0.35, 1], clamped to [0.1, 1])
Maps a value to a relative range and clamps the result within another range.
This function first calculates the relative progress of
value
withinscope
using thescoped
function. Then, it clamps the resulting progress toclamp
using theclamp
function.