Rotate Rectangler Image

Hi, I am trying to rotate an image/shape that is in a shape of a rectangle. I want to be able to rotate my image/shape from the top right corner like they do here: http://www.greensock.com/transformmanageras3/

Can someone please provide the small snippet of code to do this? I have the images/shapes center x and y position, and the mouse coordinates, but I can’t figure out the math behind this!

Please, any help is great, thanks!