normalize
Commons
stable
Re-maps a number from one numeric range to another. First normalises to [0, 1] relative to the current scale, then projects onto the new scale.
API
Signature
Full TypeScript signature sourced from the util file.
API
Parameters
Input parameters accepted by this util.
- numberrequirednumber
- The value to re-map.
- currentScaleMinrequirednumber
- The lower bound of the input range.
- currentScaleMaxrequirednumber
- The upper bound of the input range.
- newScaleMinnumber0
- The lower bound of the output range. Defaults to 0.
- newScaleMaxnumber1
- The upper bound of the output range. Defaults to 1.
API
Return value
The value returned by this util.
- The re-mapped value in [newScaleMin, newScaleMax].
Usage
Examples
Ready-to-paste usage snippets.
Map a slider value to an opacity