export function clamp(value: number, min: number, max: number) {
  return Math.min(Math.max(value, min), max)
}

export function invLerp(min: number, max: number, value: number) {
  return (value - min) / (max - min)
}

export function lerp(from: number, to: number, at: number) {
  return from + (to - from) * at
}

export function remap(
  fromMin: number,
  fromMax: number,
  toMin: number,
  toMax: number,
  value: number
) {
  let relValue = invLerp(fromMin, fromMax, value)
  return lerp(toMin, toMax, relValue)
}
