@@ -6,6 +6,7 @@ var EllipseCurve = require('./curves/ellipse/EllipseCurve');
66var GameObjectFactory = require ( '../scene/plugins/GameObjectFactory' ) ;
77var LineCurve = require ( './curves/line/LineCurve' ) ;
88var MoveTo = require ( './MoveTo' ) ;
9+ var Rectangle = require ( '../geom/rectangle/Rectangle' ) ;
910var SplineCurve = require ( './curves/spline/SplineCurve' ) ;
1011var Vector2 = require ( '../math/Vector2' ) ;
1112
@@ -112,6 +113,42 @@ var Path = new Class({
112113 return this . ellipseTo ( radius , radius , 0 , 360 , clockwise , rotation ) ;
113114 } ,
114115
116+ getBounds : function ( out , accuracy )
117+ {
118+ if ( out === undefined ) { out = new Rectangle ( ) ; }
119+ if ( accuracy === undefined ) { accuracy = 16 ; }
120+
121+ out . x = Number . MAX_SAFE_INTEGER ;
122+ out . y = Number . MAX_SAFE_INTEGER ;
123+
124+ var bounds = new Rectangle ( ) ;
125+ var maxRight = Number . MIN_SAFE_INTEGER ;
126+ var maxBottom = Number . MIN_SAFE_INTEGER ;
127+
128+ for ( var i = 0 ; i < this . curves . length ; i ++ )
129+ {
130+ var curve = this . curves [ i ] ;
131+
132+ if ( ! curve . active )
133+ {
134+ continue ;
135+ }
136+
137+ curve . getBounds ( bounds , accuracy ) ;
138+
139+ out . x = Math . min ( out . x , bounds . x ) ;
140+ out . y = Math . min ( out . y , bounds . y ) ;
141+
142+ maxRight = Math . max ( maxRight , bounds . right ) ;
143+ maxBottom = Math . max ( maxBottom , bounds . bottom ) ;
144+ }
145+
146+ out . right = maxRight ;
147+ out . bottom = maxBottom ;
148+
149+ return out ;
150+ } ,
151+
115152 toJSON : function ( )
116153 {
117154 var out = [ ] ;
0 commit comments