Here you can find the source of map(in_min, in_max, out_min, out_max)
Number.prototype.map = function (in_min, in_max, out_min, out_max) { return (this - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; } // map one number range to another http://stackoverflow.com/a/10756409 function convertToRange(value, srcRange, dstRange){ // value is outside source range return if (value < srcRange[0] || value > srcRange[1]){ return NaN; }/*from w w w . j a v a 2s . co m*/ var srcMax = srcRange[1] - srcRange[0], dstMax = dstRange[1] - dstRange[0], adjValue = value - srcRange[0]; return (adjValue * dstMax / srcMax) + dstRange[0]; }
Number.prototype.map = function ( in_min , in_max , out_min , out_max ) { return ( this - in_min ) * ( out_max - out_min ) / ( in_max - in_min ) + out_min;
Number.prototype.map = function (in_min, in_max, out_min, out_max) { return (this - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; Math.radians = function(degrees) { return degrees * Math.PI / 180; };
Number.prototype.map = function (in_min, in_max, out_min, out_max) { return (this - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; };
Number.prototype.map = function (in_min, in_max, out_min, out_max) { return (this - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
Number.prototype.map = function (istart, istop, ostart, ostop) { return ostart + (ostop - ostart) * ((this - istart) / (istop - istart)); };
Number.prototype.limit = function(min, max) { var i = this; if (i < min) i = min; if (i > max) i = max; return i; };
Number.prototype.limit = function (min, max) { return Math.min(max, Math.max(min, this)); };