@phucbm/lerp
v1.0.1
Published
A lightweight TypeScript utility function for linear interpolation
Downloads
127
Maintainers
Readme
🎯 Lerp
A lightweight TypeScript utility function for linear interpolation.
Installation
npm i @phucbm/lerppnpm add @phucbm/lerpUsage
import { lerp } from '@phucbm/lerp'
// or
import lerp from '@phucbm/lerp'
// Basic usage
lerp(0, 100, 0.5) // 50
// With default fraction (0.1)
lerp(0, 100) // 10
// Smooth animation
let current = 0
const target = 100
current = lerp(current, target, 0.2) // Moves 20% closer to targetAPI
lerp(start: number, end: number, fraction?: number): numberstart- Starting valueend- Target valuefraction- Interpolation factor (default: 0.1)0= no change1= instant change0.1= move 10% closer to target
License
MIT © phucbm
