Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript scale values

function convertRange( value, r1, r2 ) { 
    return ( value - r1[ 0 ] ) * ( r2[ 1 ] - r2[ 0 ] ) / ( r1[ 1 ] - r1[ 0 ] ) + r2[ 0 ];
}

convertRange( 328.17, [ 300.77, 559.22 ], [ 1, 10 ] );

>>> 1.9541497388276272
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #scale #values
ADD COMMENT
Topic
Name
2+3 =