Function scale

  • Scales value from [inputA, inputB] range to [a, b] range.

    Parameters

    • a: number

      The minimum value of output range.

    • b: number

      The maximum value of output range.

    • inputA: number = 0

      The minimum value of input range.

    • inputB: number = 1

      The maximum value of input range.

    Returns Mapper<number>

    Mapper that handles the input value scaling.

    scale(0, 1, 50, 100)(75);
    // ⮕ 0.5

    scale(50, 100)(0.5);
    // ⮕ 75