scale-value
Proportionally scale a value
Installation
npm install scale-value
Usage
const scaleValue = ; // Given a value between 0 and 100, this function will return a proportional value between 0 and 50const scale = ; ; // => 0; // => 25; // => 37.5; // => 50 // You can also clamp the input value, so the output value isn't above or below the min/max; // => 100; // => 50
API
scaleValue(inputMin, inputMax, outputMin, outputMax)
Create a function to translate a value within an input range to an equivalent output range.
- inputMin (Integer) - Minimum input value.
- inputMax (Integer) - Maximum input value.
- outputMin (Integer) - Minimum output value.
- outputMax (Integer) - Maximum output value.
Returns a scale
function.
scale(n, clamp)
Scale an input value to an equivalent output value.
- n (Integer) - Input value.
- clamp (Boolean) - Clamp input value within the min/max input. Defaults to
false
.
Local Development
git clone https://github.com/gakimball/scale-valuecd scale-valuenpm installnpm test
License
MIT © Geoff Kimball