Created
November 9, 2021 09:27
-
-
Save tonkotsuboy/5dee42afb79e4f04231ef2d01a06bd4f to your computer and use it in GitHub Desktop.
Math.clamp()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Math.clamp() | |
*/ | |
export const mathClamp = (x: number, lower: number, upper: number): number => { | |
return Math.min(Math.max(x, lower), upper) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment