function clamp(value, min, max) {
  return Math.min(Math.max(value, min), max);
}
Takes a number and clamps it to within the provided bounds.
@param {number} value The input number.
@param {number} min The minimum value to return.
@param {number} max The maximum value to return.
@return {number} The input number if it is within bounds, or the nearest
    number within the bounds.