Add a rotation (in radians) to this transform in place. Returns *self*, so this method can easily be chained with more calls to :meth:`rotate`, :meth:`rotate_deg`, :meth:`translate` and :meth:`scale`.
(self, theta)
| 2030 | return self |
| 2031 | |
| 2032 | def rotate(self, theta): |
| 2033 | """ |
| 2034 | Add a rotation (in radians) to this transform in place. |
| 2035 | |
| 2036 | Returns *self*, so this method can easily be chained with more |
| 2037 | calls to :meth:`rotate`, :meth:`rotate_deg`, :meth:`translate` |
| 2038 | and :meth:`scale`. |
| 2039 | """ |
| 2040 | a = math.cos(theta) |
| 2041 | b = math.sin(theta) |
| 2042 | mtx = self._mtx |
| 2043 | # Operating and assigning one scalar at a time is much faster. |
| 2044 | (xx, xy, x0), (yx, yy, y0), _ = mtx.tolist() |
| 2045 | # mtx = [[a -b 0], [b a 0], [0 0 1]] * mtx |
| 2046 | mtx[0, 0] = a * xx - b * yx |
| 2047 | mtx[0, 1] = a * xy - b * yy |
| 2048 | mtx[0, 2] = a * x0 - b * y0 |
| 2049 | mtx[1, 0] = b * xx + a * yx |
| 2050 | mtx[1, 1] = b * xy + a * yy |
| 2051 | mtx[1, 2] = b * x0 + a * y0 |
| 2052 | self.invalidate() |
| 2053 | return self |
| 2054 | |
| 2055 | def rotate_deg(self, degrees): |
| 2056 | """ |