Skip to content

Instantly share code, notes, and snippets.

View wuhhh's full-sized avatar

Huw Roberts wuhhh

View GitHub Profile
@wuhhh
wuhhh / map.js
Created February 15, 2018 16:35 — forked from AugustMiller/map.js
Extension of the native Number class to map a number in one range to a number in another.
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;
}