range-fit
v0.1.1
Published
given a number and two ranges, fit from one range to another
Downloads
14
Readme
range-fit
given a number and two ranges, fit from one range to another. This is basically http://stackoverflow.com/questions/929103/convert-a-number-range-to-another-range-maintaining-ratio for node.
npm install range-fit
API
(value, lowerInitial, upperInitial, lowerNew, upperNew)
Given a value
, within range lowerInitial
-upperInitial
, return a value with the same ratio, between lowerNew
-upperNew
. If lowerInitial
-upperInitial
is 0, then we return lowerNew
.
Examples
var rangeFit = require('range-fit');
var twenty = rangeFit(10, 0, 100, 0, 200);
see the tests for more.
License
Licensed under the MIT License