-
Notifications
You must be signed in to change notification settings - Fork 1
Clamp
ricardoboss edited this page Sep 13, 2023
·
1 revision
clamp
is a function that returns a value that is clamped between two values.
clamp(number min, number max, number x)
-
min
is the minimum value. -
max
is the maximum value. -
x
is the value to clamp.
- If
x
is less thanmin
,min
is returned. - If
x
is greater thanmax
,max
is returned. - Otherwise,
x
is returned.
clamp(0, 10, 5) // 5
clamp(0, 10, -5) // 0
clamp(0, 10, 15) // 10
© 2023 Ricardo Boss • Licensed under MIT • Want to update this page? Edit it on GitHub and submit a pull request!