• Clamps a value within a specified range.

    This function ensures that the value a is between the min and max values. If a is less than min, it returns min; if a is greater than max, it returns max. Otherwise, it returns a itself.

    Parameters

    • a: number

      The value to clamp.

    • Optionalmin: number

      The lower bound of the clamp range. Defaults to 0.

    • Optionalmax: number

      The upper bound of the clamp range. Defaults to 1.

    Returns number

    The clamped value of a.