* @function Bounds.prototype.contains * @description 判断传入的 x,y 坐标值是否在范围内。 * @example * var bounds = new Bounds(-50,-50,40,40); * //isContains = true * var isContains = bounds.contains(40,40,true); * @param {number} x - x 坐标值。 * @param {number} y - y 坐标值。 * @pa
(x, y, inclusive)
| 427 | * @returns {boolean} 传入的 x,y 坐标是否在当前范围内。 |
| 428 | */ |
| 429 | contains(x, y, inclusive) { |
| 430 | //set default |
| 431 | if (inclusive == null) { |
| 432 | inclusive = true; |
| 433 | } |
| 434 | |
| 435 | if (x == null || y == null) { |
| 436 | return false; |
| 437 | } |
| 438 | |
| 439 | //x = Util.toFloat(x); |
| 440 | //y = Util.toFloat(y); |
| 441 | |
| 442 | var contains = false; |
| 443 | if (inclusive) { |
| 444 | contains = ((x >= this.left) && (x <= this.right) && |
| 445 | (y >= this.bottom) && (y <= this.top)); |
| 446 | } else { |
| 447 | contains = ((x > this.left) && (x < this.right) && |
| 448 | (y > this.bottom) && (y < this.top)); |
| 449 | } |
| 450 | return contains; |
| 451 | } |
| 452 | |
| 453 | /** |
| 454 | * @function Bounds.prototype.intersectsBounds |
no outgoing calls
no test coverage detected