From b76fbd3beba08c098c6d18578230f9edbc4d3a3d Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 18 Aug 2024 23:20:54 -0400 Subject: Add Int:clamped() and Num:clamped() --- api/nums.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'api/nums.md') diff --git a/api/nums.md b/api/nums.md index 5f28b1a3..5b258010 100644 --- a/api/nums.md +++ b/api/nums.md @@ -1344,3 +1344,31 @@ The Bessel function of the second kind of order 1 of `x`. >> 1.0:y1() = 0.4401 ``` + +--- + +## `clamped` + +**Description:** +Returns the given number clamped between two values so that it is within +that range. + +**Usage:** +```tomo +clamped(x, low, high: Num) -> Num +``` + +**Parameters:** + +- `x`: The number to clamp. +- `low`: The lowest value the result can take. +- `high`: The highest value the result can take. + +**Returns:** +The first argument clamped between the other two arguments. + +**Example:** +```tomo +>> 2.5:clamped(5.5, 10.5) += 5.5 +``` -- cgit v1.2.3