linear-interpolation

v2.1.1arrow_drop_down
v2.1.1
v2.1.0
v2.0.9
v2.0.8
v2.0.6
v2.0.5
v2.0.1
v1.1.1
v1.1.0
v1.0.8
v1.0.5
v1.0.4
v1.0.3
STATUS
Passing
DOWNLOADS
1,332
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
5 years ago
SIZE
529 B
Linearly interpolates between two values using the formula: (min + max - min) * amount.
1 contributor
Install linear-interpolation as a package?
Copied
npm i @bit/joshk.jotils.linear-interpolation
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.cloud
Component Example
React
React
Vue
Angular
React Native
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
toggle layout
No preview available
modifieddraft
No preview available
modifieddraft
chevron_left
chevron_right
linearInterpolation (
min:number,
max:number,
amount:number
) : number

Linearly interpolates between two values using the formula: (min + max - min) * amount. Passing amount a value of 0 will cause min to be returned, passing 1 will cause max to be returned. Trying to pass an amount greater than 1 or lesser than 0 will return.

Examples
import linearInterpolation from '@bit/joshk.jotils.linear-interpolation'
export default linearInterpolation(0, 10, .5) // return 5
import linearInterpolation from '@bit/joshk.jotils.linear-interpolation'
export default linearInterpolation(0, 5, .8) // return 4
Arguments
min: number

Source value.

max: number

Destination value.

amount: number

Value between 0 - 1.

Returns
number

Interpolated value.

Test Summary

linearInterpolation Linearly interpolates between two values using the formula: (min + max - min) * amount

Pass
Help and resources