1"""
2A number of usefull categories on Foundation classes
3"""
4__all__ = ()
5import objc
6from Foundation import NSAffineTransform
7
8
9class NSAffineTransform (objc.Category(NSAffineTransform)):
10    def rotateByDegrees_atPoint_(self, angle, point):
11        """
12        Rotate the coordinatespace ``angle`` degrees around
13        ``point``.
14        """
15        self.rotateByDegrees_(angle)
16
17        tf = NSAffineTransform.transform()
18        tf.rotateByDegrees_(-angle)
19        oldPt = tf.transformPoint_(point)
20        oldPt.x -= point.x
21        oldPt.y -= point.y
22        self.translateXBy_yBy_(oldPt.x, oldPt.y)
23
24    def rotateByRadians_atPoint_(self, angle, point):
25        """
26        Rotate the coordinatespace ``angle`` radians around
27        ``point``.
28        """
29        self.rotateByRadians_(angle)
30
31        tf = NSAffineTransform.transform()
32        tf.rotateByRadians_(-angle)
33        oldPt = tf.transformPoint_(point)
34        oldPt.x -= point.x
35        oldPt.y -= point.y
36        self.translateXBy_yBy_(oldPt.x, oldPt.y)
37