was.js – Diff between revs 34 and 41
?pathlinks?
Rev 34 | Rev 41 | |||
---|---|---|---|---|
1 | /*************************************************************************/ |
1 | /*************************************************************************/ |
|
2 | /* Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 */ |
2 | /* Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 */ |
|
3 | /*************************************************************************/ |
3 | /*************************************************************************/ |
|
4 | function wasMapValueToRange(value, xMin, xMax, yMin, yMax) { |
4 | function wasMapValueToRange(value, xMin, xMax, yMin, yMax) { |
|
5 | return yMin + ( |
5 | return yMin + ( |
|
6 | ( yMax - yMin ) * ( value - xMin ) / ( xMax - xMin ) |
6 | ( yMax - yMin ) * ( value - xMin ) / ( xMax - xMin ) |
|
7 | ); |
7 | ); |
|
8 | } |
8 | } |
|
9 | |
9 | |
|
10 | /*************************************************************************/ |
10 | /*************************************************************************/ |
|
11 | /* Node.JS package export. */ |
11 | /* Node.JS package export. */ |
|
12 | /*************************************************************************/ |
12 | /*************************************************************************/ |
|
13 | if(typeof variable !== 'undefined') { |
13 | if(typeof module !== 'undefined' && typeof module.exports !== 'undefined') { |
|
14 | module.exports.mathematics = { |
14 | module.exports.mathematics = { |
|
15 | MapValueToRange: wasMapValueToRange |
15 | MapValueToRange: wasMapValueToRange |
|
16 | }; |
16 | }; |
|
17 | } |
17 | } |
|
18 | |
18 | |
|
19 | |
19 | |
|
20 |
|
20 |
|
|
21 | |
21 | |
|
22 | |
22 | |
|
23 | |
23 | |