A lightweight TypeScript utility function for linear interpolation
npm install @phucbm/lerpA lightweight TypeScript utility function for linear interpolation.






``bash`
npm i @phucbm/lerp`bash`
pnpm add @phucbm/lerp
`typescript
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 target
`
`typescript`
lerp(start: number, end: number, fraction?: number): number
- start - Starting valueend
- - Target value fraction
- - Interpolation factor (default: 0.1)0
- = no change1
- = instant change0.1` = move 10% closer to target
-
MIT © phucbm