Ejemplo n.º 1
0
    def _transform_surf(self):
        """Transformation of the surface

        Set the surface to the angle, flip, anchor and scale
        """
        self._surf = self._orig_surf
        p = self.pos

        if self._scale != 1:
            size = self._orig_surf.get_size()
            self._surf = pygame.transform.scale(self._surf, (int(size[0] * self._scale), int(size[1] * self._scale)))

        self._surf = pygame.transform.flip(self._surf, self._flip_x, self._flip_y)

        self._surf = pygame.transform.rotate(self._surf, self._angle)

        self.width, self.height = self._surf.get_size()
        w, h = self._orig_surf.get_size()
        ax, ay = self._untransformed_anchor
        anchor = transform_anchor(ax, ay, w, h, self._angle)
        self._anchor = (anchor[0] * self._scale, anchor[1] * self._scale)

        self.pos = p
        self._mask = None
Ejemplo n.º 2
0
 def test_45deg(self):
     assertVecEqual(transform_anchor(5, 5, 10, 10, 45),
                    (5 * root2, 5 * root2))
Ejemplo n.º 3
0
 def test_45deg_offset(self):
     assertVecEqual(transform_anchor(0, 0.5, 1, 1, 45),
                    (0.25 * root2, 0.75 * root2))
Ejemplo n.º 4
0
 def test_identity(self):
     assertVecEqual(transform_anchor(5, 5, 10, 10, 0), (5, 5))