Keep value between min and max: replace values outside the range with the nearest boundary. Reversed boundaries are accepted.
Syntax
clamp(value, min, max, /)Parameters
| Name | Description |
|---|---|
valueInt | Float | Input value Required · Positional only No default |
minInt | Float | Lower bound Required · Positional only No default |
maxInt | Float | Upper bound Required · Positional only No default |
Returns
Float — Clamped numeric value.Example
safe = clamp(135, 0, 100)
text(str(safe))