Skip to main content

.lerp()

LERP stands for Linear Interpolation; a mathematical function in which a value interpolates between 'start' and 'end' values. Formula: start + (end - start) * t

Syntax

return #fs.scripts.lib().lerp(/* t: */ 0.5, /* start: */ 0, /* end: */ 10);

Parameters

t

The interpolation factor, usually between 0 and 1. If t is 0 the result is equal to Start. When the value is 1, the result is equal to End. Values between 0 and 1 will interpolate between Start and End.

Start

The starting value.

End

The ending value.

Return

Returns a number.

5

Example

function(context, args) {
const l = #fs.scripts.lib();
return l.lerp(0.5, 0, 10);
}