Set or return the current transformation matrix of the turtle shape. Optional arguments: t11, t12, t21, t22 -- numbers. If none of the matrix elements are given, return the transformation matrix. Otherwise set the given elements and transform the turtleshape
(self, t11=None, t12=None, t21=None, t22=None)
| 3028 | self.tiltangle(angle + self.tiltangle()) |
| 3029 | |
| 3030 | def shapetransform(self, t11=None, t12=None, t21=None, t22=None): |
| 3031 | """Set or return the current transformation matrix of the turtle shape. |
| 3032 | |
| 3033 | Optional arguments: t11, t12, t21, t22 -- numbers. |
| 3034 | |
| 3035 | If none of the matrix elements are given, return the transformation |
| 3036 | matrix. |
| 3037 | Otherwise set the given elements and transform the turtleshape |
| 3038 | according to the matrix consisting of first row t11, t12 and |
| 3039 | second row t21, 22. |
| 3040 | Modify stretchfactor, shearfactor and tiltangle according to the |
| 3041 | given matrix. |
| 3042 | |
| 3043 | Examples (for a Turtle instance named turtle): |
| 3044 | >>> turtle.shape("square") |
| 3045 | >>> turtle.shapesize(4,2) |
| 3046 | >>> turtle.shearfactor(-0.5) |
| 3047 | >>> turtle.shapetransform() |
| 3048 | (4.0, -1.0, -0.0, 2.0) |
| 3049 | """ |
| 3050 | if t11 is t12 is t21 is t22 is None: |
| 3051 | return self._shapetrafo |
| 3052 | m11, m12, m21, m22 = self._shapetrafo |
| 3053 | if t11 is not None: m11 = t11 |
| 3054 | if t12 is not None: m12 = t12 |
| 3055 | if t21 is not None: m21 = t21 |
| 3056 | if t22 is not None: m22 = t22 |
| 3057 | if t11 * t22 - t12 * t21 == 0: |
| 3058 | raise TurtleGraphicsError("Bad shape transform matrix: must not be singular") |
| 3059 | self._shapetrafo = (m11, m12, m21, m22) |
| 3060 | alfa = math.atan2(-m21, m11) % math.tau |
| 3061 | sa, ca = math.sin(alfa), math.cos(alfa) |
| 3062 | a11, a12, a21, a22 = (ca*m11 - sa*m21, ca*m12 - sa*m22, |
| 3063 | sa*m11 + ca*m21, sa*m12 + ca*m22) |
| 3064 | self._stretchfactor = a11, a22 |
| 3065 | self._shearfactor = a12/a22 |
| 3066 | self._tilt = alfa |
| 3067 | self.pen(resizemode="user") |
| 3068 | |
| 3069 | |
| 3070 | def _polytrafo(self, poly): |
nothing calls this directly
no test coverage detected