Calculates new vector components that are proportionally the same distance between two vectors.
lerp() can use separate numbers, as in v.lerp(3, 3, 0.5), another p5.Vector object, as in v.lerp(v2, 0.5), or an array of numbers, as in v.lerp([3, 3], 0.5). When using numbers, the last argument is always the interpolation amount.
The amt parameter is the amount to interpolate between the old vector and the new vector. 0.0 keeps all components equal to the old vector's, 0.5 is halfway between, and 1.0 sets all components equal to the new vector's. Values of amt outside the range 0 to 1 are allowed and extrapolate beyond the target.
This method supports N-dimensional vectors. You should interpolate vectors only when they are the same size. When two vectors of different sizes are used, the smaller dimension will be used, and any additional values of the longer vector will be ignored.
The static version of lerp(), as in p5.Vector.lerp(v0, v1, 0.5), returns a new p5.Vector object and doesn't change the originals.
Examples
Syntax
lerp(args1, args2, ..., argsn)
lerp(arr, amt)
lerp(v, amt)
Parameters
amt (0.0 keeps the old vector, 1.0 the new vector, 0.5 is halfway between).Related References
textToContours
Returns an array of arrays of points outlining a string of text written using the font.
textToModel
Converts text into a 3D model that can be rendered in WebGL mode.
textToPaths
Returns a flat array of path commands that describe the outlines of a string of text.
textToPoints
Returns an array of points outlining a string of text written using the font.