(rectA, rectB, output)
| 26 | * @return {Phaser.Geom.Rectangle} A rectangle object with intersection data. |
| 27 | */ |
| 28 | var GetRectangleIntersection = function (rectA, rectB, output) |
| 29 | { |
| 30 | if (output === undefined) { output = new Rectangle(); } |
| 31 | |
| 32 | if (RectangleToRectangle(rectA, rectB)) |
| 33 | { |
| 34 | output.x = Math.max(rectA.x, rectB.x); |
| 35 | output.y = Math.max(rectA.y, rectB.y); |
| 36 | output.width = Math.min(rectA.right, rectB.right) - output.x; |
| 37 | output.height = Math.min(rectA.bottom, rectB.bottom) - output.y; |
| 38 | } |
| 39 | |
| 40 | return output; |
| 41 | }; |
| 42 | |
| 43 | module.exports = GetRectangleIntersection; |
no test coverage detected
searching dependent graphs…