2018-02-12 16:01:20 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
2019-01-15 16:20:22 +00:00
|
|
|
* @copyright 2019 Photon Storm Ltd.
|
2019-05-10 15:15:04 +00:00
|
|
|
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
2018-02-12 16:01:20 +00:00
|
|
|
*/
|
|
|
|
|
2016-12-07 20:37:03 +00:00
|
|
|
/**
|
2017-10-06 05:16:31 +00:00
|
|
|
* Checks if the two values are within the given `tolerance` of each other.
|
|
|
|
*
|
|
|
|
* @function Phaser.Math.Within
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2018-04-24 06:22:52 +00:00
|
|
|
* @param {number} a - The first value to use in the calculation.
|
|
|
|
* @param {number} b - The second value to use in the calculation.
|
2017-10-06 05:16:31 +00:00
|
|
|
* @param {number} tolerance - The tolerance. Anything equal to or less than this value is considered as being within range.
|
|
|
|
*
|
|
|
|
* @return {boolean} Returns `true` if `a` is less than or equal to the tolerance of `b`.
|
|
|
|
*/
|
2016-12-07 20:37:03 +00:00
|
|
|
var Within = function (a, b, tolerance)
|
|
|
|
{
|
|
|
|
return (Math.abs(a - b) <= tolerance);
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = Within;
|