UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

24 lines (20 loc) 798 B
import { inverseLerp } from "./inverseLerp.js"; import { lerp } from "./lerp.js"; /** * Returns linear remapping of {@link value} from source range [source_first, source_second] to target range [target_first, target_second] * This method is non-clamping, meaning that if your input is outside the source range - output will be outside the target range as well * @param {number} source_first * @param {number} source_second * @param {number} target_first * @param {number} target_second * @param {number} value * @return {number} */ export function remap( source_first, source_second, target_first, target_second, value ) { const relative = inverseLerp(source_first, source_second, value); return lerp(target_first, target_second, relative); }