File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -312,6 +312,32 @@ PIXI.Sprite.prototype.getBounds = function(matrix)
312312 return bounds ;
313313} ;
314314
315+ /**
316+ * Retrieves the non-global local bounds of the Sprite as a rectangle. The calculation takes all visible children into consideration.
317+ *
318+ * @method getLocalBounds
319+ * @return {Rectangle } The rectangular bounding area
320+ */
321+ PIXI . Sprite . prototype . getLocalBounds = function ( ) {
322+ var matrixCache = this . worldTransform ;
323+
324+ this . worldTransform = PIXI . identityMatrix ;
325+
326+ for ( var i = 0 ; i < this . children . length ; i ++ ) {
327+ this . children [ i ] . updateTransform ( ) ;
328+ }
329+
330+ var bounds = this . getBounds ( ) ;
331+
332+ this . worldTransform = matrixCache ;
333+
334+ for ( i = 0 ; i < this . children . length ; i ++ ) {
335+ this . children [ i ] . updateTransform ( ) ;
336+ }
337+
338+ return bounds ;
339+ } ;
340+
315341/**
316342* Renders the object using the WebGL renderer
317343*
Original file line number Diff line number Diff line change @@ -459,6 +459,32 @@ PIXI.Strip.prototype.getBounds = function(matrix)
459459 return bounds ;
460460} ;
461461
462+ /**
463+ * Retrieves the non-global local bounds of the mesh as a rectangle. The calculation takes all visible children into consideration.
464+ *
465+ * @method getLocalBounds
466+ * @return {Rectangle } The rectangular bounding area
467+ */
468+ PIXI . Strip . prototype . getLocalBounds = function ( ) {
469+ var matrixCache = this . worldTransform ;
470+
471+ this . worldTransform = PIXI . identityMatrix ;
472+
473+ for ( var i = 0 ; i < this . children . length ; i ++ ) {
474+ this . children [ i ] . updateTransform ( ) ;
475+ }
476+
477+ var bounds = this . getBounds ( ) ;
478+
479+ this . worldTransform = matrixCache ;
480+
481+ for ( i = 0 ; i < this . children . length ; i ++ ) {
482+ this . children [ i ] . updateTransform ( ) ;
483+ }
484+
485+ return bounds ;
486+ } ;
487+
462488/**
463489 * Different drawing buffer modes supported
464490 *
Original file line number Diff line number Diff line change @@ -933,6 +933,32 @@ PIXI.Graphics.prototype.getBounds = function(matrix)
933933
934934} ;
935935
936+ /**
937+ * Retrieves the non-global local bounds of the graphic shape as a rectangle. The calculation takes all visible children into consideration.
938+ *
939+ * @method getLocalBounds
940+ * @return {Rectangle } The rectangular bounding area
941+ */
942+ PIXI . Graphics . prototype . getLocalBounds = function ( ) {
943+ var matrixCache = this . worldTransform ;
944+
945+ this . worldTransform = PIXI . identityMatrix ;
946+
947+ for ( var i = 0 ; i < this . children . length ; i ++ ) {
948+ this . children [ i ] . updateTransform ( ) ;
949+ }
950+
951+ var bounds = this . getBounds ( ) ;
952+
953+ this . worldTransform = matrixCache ;
954+
955+ for ( i = 0 ; i < this . children . length ; i ++ ) {
956+ this . children [ i ] . updateTransform ( ) ;
957+ }
958+
959+ return bounds ;
960+ } ;
961+
936962/**
937963* Tests if a point is inside this graphics object
938964*
You can’t perform that action at this time.
0 commit comments