Created
July 2, 2015 14:36
-
-
Save WillSquire/c8187e511a8b2220b701 to your computer and use it in GitHub Desktop.
Clamp - Clamps a value to within the min or max values given.
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
/** | |
* Clamps a value to within the min or max values given. | |
* | |
* @param {number} value | |
* @param {number} min | |
* @param {number} max | |
* @returns {number} | |
*/ | |
function clamp(value, min, max) { | |
return Math.min(Math.max(value, min), max); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment