Function clamp

  • Return a value that is clamped between two inclusive bounds.

    Returns

    returns value if within bounds, otherwise the closest bound

    Example

    clamp(10, 3, 12) === 10
    clamp(1, 3, 12) === 3
    clamp(20, 3, 12) === 12

    Parameters

    • value: number

      the value to clamp

    • min: number

      the minimum bound

    • max: number

      the maximum bound

    Returns number

Generated using TypeDoc