Skip to content

Lerp

Linearly interpolates between two values.

syntax
function lerp(start: Vec, end: Vec, progress: number): Vec;

Usage

See: VectorToColor

example
import { lerp, vecToRGB } from 'animare/plugins';
const red = [255, 0, 0];
const blue = [0, 0, 255];
const mixed = lerp(red, blue, 0.5);
const rgbString = vecToRGB(mixed);

start

start: Vec Required

The starting value. Accepts a number, 1D, 2D, 3D or 4D vector.

Single Value number
1D Vector [number] | { x: number }
2D Vector [number, number] | { x: number, y: number }
3D Vector [number, number, number] | { x: number, y: number, z: number }
4D Vector [number, number, number, number] | { x: number, y: number, z: number, w: number }

end

end: Vec Required

The ending value. Accepts a number, 1D, 2D, 3D or 4D vector.

Single Value number
1D Vector [number] | { x: number }
2D Vector [number, number] | { x: number, y: number }
3D Vector [number, number, number] | { x: number, y: number, z: number }
4D Vector [number, number, number, number] | { x: number, y: number, z: number, w: number }

progress

progress: number Required

The interpolation value (ranges from 0 to 1) between the two values.

Returns

Returns a value between the two values.