lerp
Calculates a value that is a linear combination of two other values based on the interpolation factor.
Installation
npm install @madeinhaus/utilsImport
import { lerp } from '@madeinhaus/utils';Parameters
a(number): The start value.b(number): The end value.t(number): The interpolation factor between0and1.
Returns
- (number): The interpolated value between
aandb.
Usage
import { lerp } from '@madeinhaus/utils';
const startValue = 0;
const endValue = 100;
const interpolationFactor = 0.5;
const interpolatedValue = lerp(startValue, endValue, interpolationFactor); // 50In this example, we import the lerp function from the @madeinhaus/utils package and use it to linearly interpolate between two values.