HexagonJS
Edit Page
Interpolate
Linear interpolation for numbers and strings
Examples
Api
Functions
hx.interpolateaNumberbNumberFunction
Returns a interpolator function for values between two numbers.
hx.interpolate(100, 200)(0.5)// Returns 150
Arguments
The first number to compare
The second number to compare
Returns
functionalphaNumberNumber
A function that accepts a single value between 0 and 1 as a percentage point between the two values input in the interpolate function.
Arguments
alphaNumber
Returns
hx.interpolateaStringbStringFunction
Returns a interpolator function for values between two strings. All comparable numbers embedded in the strings will be interpolated.
hx.interpolate("rgba(255,0,0,1)", "rgba(0,0,255,1)")(0.5) // Returns rgba(128,0,128,1)"
hx.interpolate("Number 1: 500px;", "Number 1: 200px;")(0.5)// Returns "Number 1: 350px;"
Arguments
The first string to compare
The second string to compare
Returns
functionalphaNumberString
A function that accepts a single value between 0 and 1 as a percentage point between the two values input in the interpolate function.
Arguments
alphaNumber
Returns