Skip to content

mattdesl/lerp-array

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lerp-array

stable

Quickly lerps two numbers or two parallel arrays of numbers (e.g. vectors, colors, etc).

var lerp = require('lerp-array')

//RGB colors
var color1 = [0, 255, 0]
var color2 = [255, 0, 0]

//lerp the two
var color3 = lerp(color1, color2, 0.5)

Usage

NPM

lerp(v1, v2, t[, out])

Linearly interpolates v1 to v2 using the t component. If both v1 and v2 are number types, this is equivalent to a straight lerp. If the two are array types, they are lerped in parallel. This assumes both arrays are the same length (only uses the length of v1).

You can optionally specify an out parameter to re-use an array object. Otherwise, a new one will be created.

If the two arrays have different sizes, the length of the smallest will prevail.

License

MIT, see LICENSE.md for details.

About

quickly lerps two numbers or an array of numbers

Resources

License

Stars

Watchers

Forks

Packages

No packages published