예제 #1
0
    def test_inkscape_center(self):
        parser = SvgParser()
        element = ElementTree.Element("g")
        group = objects.Rect(NVector(100, 200), NVector(300, 400))
        dest_transform = objects.Transform()

        element.attrib[parser.qualified("inkscape", "transform-center-x")] = 0
        element.attrib[parser.qualified("inkscape", "transform-center-y")] = 0
        parser.parse_transform(element, group, dest_transform)
        self.assert_transform(
            dest_transform,
            anchor_point=NVector(100, 200),
            position=NVector(100, 200),
            scale=NVector(100, 100),
            rotation=0,
            skew_axis=0,
            skew=0,
        )

        element.attrib[parser.qualified("inkscape", "transform-center-x")] = 20
        element.attrib[parser.qualified("inkscape", "transform-center-y")] = -30
        parser.parse_transform(element, group, dest_transform)
        self.assert_transform(
            dest_transform,
            anchor_point=NVector(120, 230),
            position=NVector(120, 230),
            scale=NVector(100, 100),
            rotation=0,
            skew_axis=0,
            skew=0,
        )
예제 #2
0
    def test_multi_trans(self):
        parser = SvgParser()
        element = ElementTree.Element("g")
        group = objects.Rect(NVector(100, 200), NVector(300, 400))
        dest_transform = objects.Transform()

        element.attrib["transform"] = "scale(0.7, 0.5) rotate(45) translate(12, 34)"
        parser.parse_transform(element, group, dest_transform)
        self.assert_transform(
            dest_transform,
            anchor_point=NVector(0, 0),
            position=NVector(12, 34),
            scale=NVector(70, 50),
            rotation=45,
            skew_axis=0,
            skew=0,
        )
예제 #3
0
    def test_matrix(self):
        parser = SvgParser()
        element = ElementTree.Element("g")
        group = objects.Rect(NVector(100, 200), NVector(300, 400))
        dest_transform = objects.Transform()

        m = TransformMatrix()
        m.scale(0.7, 0.5)
        m.rotate(-math.pi/4)
        m.translate(12, 34)
        element.attrib["transform"] = m.to_css_2d()
        parser.parse_transform(element, group, dest_transform)
        self.assert_transform(
            dest_transform,
            anchor_point=NVector(0, 0),
            position=NVector(12, 34),
            scale=NVector(70, 50),
            rotation=45,
            skew_axis=0,
            skew=0,
        )