npm.nicfv.com

    Function clamp

    • Clamp a number within a range.

      Parameters

      • n: number

        The number to clamp

      • min: number

        The minimum value of the range

      • max: number

        The maximum value of the range

      Returns number

      A clamped number

      const n1 = SMath.clamp(5, 0, 10),  // 5
      n2 = SMath.clamp(-2, 0, 10); // 0
    MMNEPVFCICPMFPCPTTAAATR