|
1 | 1 | var Rectangle = require('../../geom/rectangle/Rectangle'); |
| 2 | +var RotateAround = require('../../math/RotateAround'); |
| 3 | +var Vector2 = require('../../math/Vector2'); |
2 | 4 |
|
3 | 5 | var GetBounds = { |
4 | 6 |
|
| 7 | + getTopLeft: function (output) |
| 8 | + { |
| 9 | + if (output === undefined) { output = new Vector2(); } |
| 10 | + |
| 11 | + output.x = this.x - (this.displayWidth * this.originX); |
| 12 | + output.y = this.y - (this.displayHeight * this.originY); |
| 13 | + |
| 14 | + if (this.rotation !== 0) |
| 15 | + { |
| 16 | + RotateAround(output, this.x, this.y, this.rotation); |
| 17 | + } |
| 18 | + |
| 19 | + return output; |
| 20 | + }, |
| 21 | + |
| 22 | + getTopRight: function (output) |
| 23 | + { |
| 24 | + if (output === undefined) { output = new Vector2(); } |
| 25 | + |
| 26 | + output.x = (this.x - (this.displayWidth * this.originX)) + this.displayWidth; |
| 27 | + output.y = this.y - (this.displayHeight * this.originY); |
| 28 | + |
| 29 | + if (this.rotation !== 0) |
| 30 | + { |
| 31 | + RotateAround(output, this.x, this.y, this.rotation); |
| 32 | + } |
| 33 | + |
| 34 | + return output; |
| 35 | + }, |
| 36 | + |
| 37 | + getBottomLeft: function (output) |
| 38 | + { |
| 39 | + if (output === undefined) { output = new Vector2(); } |
| 40 | + |
| 41 | + output.x = this.x - (this.displayWidth * this.originX); |
| 42 | + output.y = (this.y - (this.displayHeight * this.originY)) + this.displayHeight; |
| 43 | + |
| 44 | + if (this.rotation !== 0) |
| 45 | + { |
| 46 | + RotateAround(output, this.x, this.y, this.rotation); |
| 47 | + } |
| 48 | + |
| 49 | + return output; |
| 50 | + }, |
| 51 | + |
| 52 | + getBottomRight: function (output) |
| 53 | + { |
| 54 | + if (output === undefined) { output = new Vector2(); } |
| 55 | + |
| 56 | + output.x = (this.x - (this.displayWidth * this.originX)) + this.displayWidth; |
| 57 | + output.y = (this.y - (this.displayHeight * this.originY)) + this.displayHeight; |
| 58 | + |
| 59 | + if (this.rotation !== 0) |
| 60 | + { |
| 61 | + RotateAround(output, this.x, this.y, this.rotation); |
| 62 | + } |
| 63 | + |
| 64 | + return output; |
| 65 | + }, |
| 66 | + |
5 | 67 | getBounds: function (output) |
6 | 68 | { |
7 | 69 | if (output === undefined) { output = new Rectangle(); } |
8 | 70 |
|
9 | | - var x = this.x - this.displayOriginX; |
10 | | - var y = this.y - this.displayOriginY; |
| 71 | + var tmp = new Vector2(); |
| 72 | + |
| 73 | + this.getTopLeft(tmp); |
| 74 | + |
| 75 | + var topRight = this.getTopRight(); |
| 76 | + var bottomLeft = this.getBottomLeft(); |
| 77 | + var bottomRight = this.getBottomRight(); |
| 78 | + |
| 79 | + /* |
| 80 | + var x = this.x; |
| 81 | + var y = this.y; |
11 | 82 |
|
12 | 83 | var w = this.displayWidth; |
13 | 84 | var h = this.displayHeight; |
@@ -61,6 +132,7 @@ var GetBounds = { |
61 | 132 | output.y = yMin; |
62 | 133 | output.width = xMax - xMin; |
63 | 134 | output.height = yMax - yMin; |
| 135 | + */ |
64 | 136 |
|
65 | 137 | return output; |
66 | 138 | } |
|
0 commit comments