Interpolation calculates a value between two other values. For example, the number 5 is halfway between 0 and 10. Different types of interpolation use different rates of change between values. Linear interpolation, abbreviated as lerp, uses a constant rate of change. The lerp() function linearly interpolates between two numbers.
Move the mouse across the screen and the symbol will follow. Between drawing each frame of the animation, the ellipse moves part of the distance from its current position toward the cursor.
Linear Interpolation by p5.js Contributors and the Processing Foundation is licensed under CC BY-NC-SA 4.0.
Related Examples

A small white circle on a grey background.
Linear Interpolation
Convert a number between 0 and 1 to another range.

A large yellow circle on a black background.
Map
Convert a number from one range to another range.

A small purple circle on a black background.
Random
Get random numbers.

A small white circle in a pink rectangle.
Constrain
Keep a number within a range.

A pink clock on a grey background.
Clock
Get the current time.