Skip to content

lerp

Realiza a interpolação linear entre dois valores numéricos.

Sintaxe

typescript
lerp(start: number, end: number, amount: number): number

Parameters

NameTypeDescription
startnumberInitial value.
endnumberFinal value.
amountnumberInterpolation factor (usually between 0-1).

Return

TypeDescription
numberInterpolated value between start and end.

Example

typescript
lerp(0, 10, 0.5); // 5
lerp(10, 20, 0.25); // 12.5

Notes

  • Throws TypeError if any argument is not a number.
  • Useful for animations, transitions, and calculating intermediate values.

References

Released under the MIT License.