Skip to content

pencil.js / math / lerp

Function: lerp() ​

ts
function lerp(
   from, 
   to, 
   ratio
): number;

Defined in: math.ts:136

Linear interpolation computation, useful when doing animation

Parameters ​

ParameterTypeDescription
fromnumberStarting value
tonumberEnding value
rationumberInterpolation ratio, 0 is the starting value and 1 the ending value

Returns ​

number

Example ​

ts
lerp(10, 20, 0.5); // => 15

Released under the MIT License.