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.

typescript

API

Parameters

Input parameters accepted by this util.

number
required
number
The value to re-map.
currentScaleMin
required
number
The lower bound of the input range.
currentScaleMax
required
number
The upper bound of the input range.
newScaleMin
number
0
The lower bound of the output range. Defaults to 0.
newScaleMax
number
1
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

typescript