//-- //-- Augmented methods for the JavaScript Number() object //-- // Clamp a number to a range Number.prototype.clamp = function(min,max) { var c = this; if(c < min) c = min; if(c > max) c = max; return Number(c); };