@@ -68,15 +68,43 @@ var GetBounds = {
6868 {
6969 if ( output === undefined ) { output = new Rectangle ( ) ; }
7070
71- var tmp = new Vector2 ( ) ;
71+ // We can use the output object to temporarily store the x/y coords in:
7272
73- this . getTopLeft ( tmp ) ;
73+ this . getTopLeft ( output ) ;
7474
75- var topRight = this . getTopRight ( ) ;
76- var bottomLeft = this . getBottomLeft ( ) ;
77- var bottomRight = this . getBottomRight ( ) ;
75+ var TLx = output . x ;
76+ var TLy = output . y ;
77+
78+ this . getTopRight ( output ) ;
79+
80+ var TRx = output . x ;
81+ var TRy = output . y ;
82+
83+ this . getBottomLeft ( output ) ;
84+
85+ var BLx = output . x ;
86+ var BLy = output . y ;
87+
88+ this . getBottomRight ( output ) ;
89+
90+ var BRx = output . x ;
91+ var BRy = output . y ;
92+
93+ output . x = Math . min ( TLx , TRx , BLx , BRx ) ;
94+ output . y = Math . min ( TLy , TRy , BLy , BRy ) ;
95+ output . width = Math . max ( TLx , TRx , BLx , BRx ) - output . x ;
96+ output . height = Math . max ( TLy , TRy , BLy , BRy ) - output . y ;
97+
98+ return output ;
99+ } ,
100+
101+ // Works but only if originX/Y = 0
102+
103+ /*
104+ getBounds: function (output)
105+ {
106+ if (output === undefined) { output = new Rectangle(); }
78107
79- /*
80108 var x = this.x;
81109 var y = this.y;
82110
@@ -132,10 +160,10 @@ var GetBounds = {
132160 output.y = yMin;
133161 output.width = xMax - xMin;
134162 output.height = yMax - yMin;
135- */
136163
137164 return output;
138165 }
166+ */
139167} ;
140168
141169module . exports = GetBounds ;
0 commit comments