getBounds() method for EaselJS DisplayObjects

Please correct me if I’m wrong here, but I was looking for a method or property to retrieve the boundaries of a DisplayObject in EaselJS – however I was not able to find it – so I wrote  my own method for this, maybe this will help someone and hopefully a method like this will be implemented into the framework in the future. If someone knows about the existence of such a method, please post it in the comments, so I can update this post.

Update (12-06-2012): I updated the snipped to work with the current easelJS version, it also includes rotation now.

Update (03-14-2013): Please refer to the following library: it contains the getBounds()-method and is regularly updated and contains bugfixes



Disclaimer: I did NO extensive testing on this method, if you find any bug, please post it in the comments, also I would like to point out that the method does NOT consider the rotation or skew parameters.

  • Pingback: Retro Style Plattform Runner Game for mobile with EaselJS (Part 2) | indiegamr

  • Tony


    it looks great, i’m testing it.
    – the algorithm for Bitmap doesn’t handle the case the bitmap is not loaded yet
    – your algorithm doesn’t handle filters as well
    But anyway, very useful job ;)

  • Tony

    Hello again,

    Just tested it..
    Actually, it does”t work. At least for containers.
    You compare to the width of children which is an undefined property as the width of the parent…

    • olsn


      i wrote this for an older version of EaselJS and have not tested or used it with the current version,
      it is possible that it might be not working correctly any more

    • olsn

      I updated the snipped, it should work with the current version of easelJS now.
      It will also take rotation into account now.


  • Muhammad

    Apparently this does not work with DisplayObject or Shape.. right?

    • olsn

      Yes, that is correct. Shapes are dynamic and it is currently not possible to get the width and hight of a Shape with a reasonable performance.
      Also I would suggest you to use this library: it contains the getBounds()-method and is regularly updated and contains bugfixes

  • moose

    I like the collision detection (and all the other stuff!), but it might be a little too much calculations for some cases with simple shapes just to get the bounds?

    Though maybe a bit sloppy, is there much harm in creating and saving an extra var like radius, width and height on a shape object like this:

    Would that slow things down a lot or generate problems for cleaning up DisplayObjects?

    Cheers! Michel

    • olsn

      You can absolutely do that – the getBounds-method here does only work for Bitmaps and BitmapAnimations – so for Shapes it’s not that simple to get the bounds.