Returns a number whose value is limited to the given range.

Example: limit the output of this computation to between 0 and 255
(x * 255).clamp(0, 255)

@param {Number} input
@param {Number} min The lower boundary of the output range
@param {Number} max The upper boundary of the output range
@returns A number in the range [min, max]
@type Number
function clamp() {
	  var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
	  var min = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
	  var max = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 255;
	  return Math.min(Math.max(input, min), max);
	}