Esempio n. 1
0
 def test_path_transform02(self):
     # See also: svg.svg
     # Mm Aa Hh Zz
     d = 'M-27-5a7,7,0,1,0,0,10h54a7,7,0,1,0,0-10z'
     path_data = PathParser.parse(d)
     matrix = DOMMatrix()
     matrix.rotate_self(rot_z=90)
     transformed = PathParser.transform(path_data, matrix)
     exp = PathParser.tostring(transformed)
     expected = 'M5,-27 A7,7 0 1 0 -5,-27 L-5,27 A7,7 0 1 0 5,27 Z'
     self.assertEqual(expected, exp)
Esempio n. 2
0
 def test_path_transform03(self):
     # See also: svg.svg
     # Mm Aa Hh Zz
     d = 'M-27-5a7,7,0,1,0,0,10h54a7,7,0,1,0,0-10z'
     path_data = PathParser.parse(d)
     matrix = DOMMatrix()
     matrix.rotate_self(rot_z=135)
     transformed = PathParser.transform(path_data, matrix)
     exp = PathParser.tostring(transformed)
     expected = "M22.627,-15.556 A7,7 0 1 0 15.556,-22.627 L-22.627,15.556" \
                " A7,7 0 1 0 -15.556,22.627 Z"
     self.assertEqual(expected, exp)
Esempio n. 3
0
    def test_transform_set_rotate(self):
        r = -30
        cx = 24
        cy = 16
        m = DOMMatrix()
        m.translate_self(cx, cy)
        m.rotate_self(rot_z=r)
        m.translate_self(-cx, -cy)

        t = SVGTransform(SVGTransform.SVG_TRANSFORM_ROTATE, r, cx, cy)
        self.assertEqual(SVGTransform.SVG_TRANSFORM_ROTATE, t.type)
        self.assertEqual('rotate(-30, 24, 16)', t.tostring())
        self.assertTrue(m == t.matrix)
        self.assertEqual(r, t.angle)

        cx = 12.3456
        cy = -0
        m = DOMMatrix()
        m.translate_self(cx, cy)
        m.rotate_self(rot_z=r)
        m.translate_self(-cx, -cy)

        t = SVGTransform()
        t.set_rotate(r, cx, cy)
        self.assertEqual(SVGTransform.SVG_TRANSFORM_ROTATE, t.type)
        self.assertEqual('rotate(-30, 12.346, 0)', t.tostring())
        self.assertTrue(m == t.matrix)
        self.assertEqual(r, t.angle)

        cx = -0
        cy = -0
        m = DOMMatrix()
        m.rotate_self(rot_z=r)

        t = SVGTransform()
        t.set_rotate(r, cx, cy)
        self.assertEqual(SVGTransform.SVG_TRANSFORM_ROTATE, t.type)
        self.assertEqual('rotate(-30)', t.tostring())
        self.assertTrue(m == t.matrix)
        self.assertEqual(r, t.angle)