Skip to content

Instantly share code, notes, and snippets.

@tonkotsuboy
Created November 9, 2021 09:27
Show Gist options
  • Save tonkotsuboy/5dee42afb79e4f04231ef2d01a06bd4f to your computer and use it in GitHub Desktop.
Save tonkotsuboy/5dee42afb79e4f04231ef2d01a06bd4f to your computer and use it in GitHub Desktop.
Math.clamp()
/**
* 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