The lerp() function is used to find a number between two numbers. The amt parameter can be used to specify the amount to interpolate between the two values. An amount nearer to 0.1 would mean that the final value is nearer to the first value, and nearer to 0.9 means that the value is nearer to the second value. If the value is less or more than these, then the final value would be calculated on the basis of the ratio of the two numbers.
It can be used for drawing dotted lines or creating motion along a path by finding all the intermediate points in a line.
lerp( start, stop, amt )
Parameters: This function accept three parameters as mentioned above and described below:
- start: It is a number which denotes the first value of the two numbers.
- stop: It is a number which denotes the second value of the two numbers..
- amt: It is a number which denotes the amount by which a number is to be interpolated between the two numbers.
Return Value: It returns a number with the lerped value.
Below examples illustrate the lerp() function in p5.js:
Online editor: https://editor.p5js.org/
- How to get the function name inside a function in PHP ?
- PHP | Ds\Set add() Function
- PHP | ord() Function
- D3.js | d3.max() function
- PHP | cos( ) Function
- p5.js | sin() function
- p5.js | tan() function
- p5.js | log() function
- PHP | Ds\Set xor() Function
- PHP | each() Function
- p5.js | cos() function
- PHP | min( ) Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.