mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-24 20:37:59 +01:00
13 lines
468 B
TypeScript
13 lines
468 B
TypeScript
|
// Simple linear interpolation.
|
||
|
// Returns a value between min and max based on a delta.
|
||
|
// The delta is a number between 0 and 1.
|
||
|
// If the delta is not within the 0-1 range, this function will
|
||
|
// clamp the value between min and max, depending on whether
|
||
|
// the delta >= 1 or <= 0.
|
||
|
export function lerp(delta: number, from: number, to: number): number {
|
||
|
if (delta >= 1) { return to; }
|
||
|
else if (delta <= 0) { return from; }
|
||
|
|
||
|
return from + (to - from) * delta;
|
||
|
}
|