Commit fb416f7c authored by Martin Owens's avatar Martin Owens 🤖

Fix #224 by applying transforms to paths correctly.

parent 86dc2f06
Pipeline #146897898 passed with stages
in 3 minutes and 53 seconds
......@@ -44,8 +44,7 @@ class PathElementBase(ShapeElement):
def apply_transform(self):
"""Apply the internal transformation to this node and delete"""
if 'transform' in self.attrib:
self.path.transform(self.transform)
self.set('d', str(self.path))
self.path = self.path.transform(self.transform)
self.set('transform', Transform())
@property
......
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:svg="http://www.w3.org/2000/svg" width="1200">
<defs><font horiz-adv-x="1200" horiz-origin-y="0"><font-face font-family="SVGFont" units-per-em="1200" cap-height="0" x-height="0" ascent="0" descent="0"/><glyph unicode="A" d=" M 100 700 L 100 500 L 359 500 l -183 -183 l 141 -141 l 183 183 L 500 100 L 700 100 L 700 359 l 183 -183 l 141 141 l -183 183 L 1100 500 L 1100 700 L 841 700 l 183 183 l -141 141 l -183 -183 L 700 1100 L 500 1100 L 500 841 l -183 183 l -141 -141 l 183 -183 L 100 700 z"/><glyph unicode="B" d=" M 0 800 L 0 500 L 400 500 L 400 100 L 700 100 L 700 500 L 1100 500 L 1100 800 L 700 800 L 700 1200 L 400 1200 L 400 800 L 0 800 z"/><glyph unicode="C" d=" M 100 700 l 100 -100 L 313 600 q 0 -47 5 -100 L 100 500 l 100 -100 L 335 400 q 37 -167 112 -257 q 117 -141 297 -141 q 242 0 354 189 q 60 103 66 209 L 983 400 q 0 -55 -25.5 -99 t -63.5 -68 t -75 -36.5 t -67 -12.5 q -24 0 -52.5 10 t -62.5 32 t -65.5 67 t -50.5 107 L 900 400 l -100 100 L 500 500 q -6 46 -6 100 L 900 600 l -100 100 L 500 700 q 9 74 33 132 t 52.5 91 t 62 54.5 t 59 29 t 46.5 7.5 q 29 0 66 -13 t 75 -37 t 63.5 -67.5 t 25.5 -96.5 L 1157 800 q -31 172 -128 278 q -107 117 -274 117 q -205 0 -324 -158 q -36 -46 -69 -131.5 t -45 -205.5 L 100 700 z"/></font></defs><sodipodi:namedview/><g inkscape:label="GlyphLayer-A" inkscape:groupmode="layer"><path d="M 100 700 L 100 500 L 359 500 l -183 -183 l 141 -141 l 183 183 L 500 100 L 700 100 L 700 359 l 183 -183 l 141 141 l -183 183 L 1100 500 L 1100 700 L 841 700 l 183 183 l -141 141 l -183 -183 L 700 1100 L 500 1100 L 500 841 l -183 183 l -141 -141 l 183 -183 L 100 700 z"/></g><g inkscape:label="GlyphLayer-B" inkscape:groupmode="layer" style="display:none"><path d="M 0 800 L 0 500 L 400 500 L 400 100 L 700 100 L 700 500 L 1100 500 L 1100 800 L 700 800 L 700 1200 L 400 1200 L 400 800 L 0 800 z"/></g><g inkscape:label="GlyphLayer-C" inkscape:groupmode="layer" style="display:none"><path d="M 100 700 l 100 -100 L 313 600 q 0 -47 5 -100 L 100 500 l 100 -100 L 335 400 q 37 -167 112 -257 q 117 -141 297 -141 q 242 0 354 189 q 60 103 66 209 L 983 400 q 0 -55 -25.5 -99 t -63.5 -68 t -75 -36.5 t -67 -12.5 q -24 0 -52.5 10 t -62.5 32 t -65.5 67 t -50.5 107 L 900 400 l -100 100 L 500 500 q -6 46 -6 100 L 900 600 l -100 100 L 500 700 q 9 74 33 132 t 52.5 91 t 62 54.5 t 59 29 t 46.5 7.5 q 29 0 66 -13 t 75 -37 t 63.5 -67.5 t 25.5 -96.5 L 1157 800 q -31 172 -128 278 q -107 117 -274 117 q -205 0 -324 -158 q -36 -46 -69 -131.5 t -45 -205.5 L 100 700 z"/></g></svg>
\ No newline at end of file
<defs><font horiz-adv-x="1200" horiz-origin-y="0"><font-face font-family="SVGFont" units-per-em="1200" cap-height="0" x-height="0" ascent="0" descent="0"/><glyph unicode="A" d=" M 100 -1900 L 100 -1700 L 359 -1700 l -183 183 l 141 141 l 183 -183 L 500 -1300 L 700 -1300 L 700 -1559 l 183 183 l 141 -141 l -183 -183 L 1100 -1700 L 1100 -1900 L 841 -1900 l 183 -183 l -141 -141 l -183 183 L 700 -2300 L 500 -2300 L 500 -2041 l -183 -183 l -141 141 l 183 183 L 100 -1900 z"/><glyph unicode="B" d=" M 0 -2000 L 0 -1700 L 400 -1700 L 400 -1300 L 700 -1300 L 700 -1700 L 1100 -1700 L 1100 -2000 L 700 -2000 L 700 -2400 L 400 -2400 L 400 -2000 L 0 -2000 z"/><glyph unicode="C" d=" M 100 -1900 l 100 100 L 313 -1800 q 0 47 5 100 L 100 -1700 l 100 100 L 335 -1600 q 37 167 112 257 q 117 141 297 141 q 242 0 354 -189 q 60 -103 66 -209 L 983 -1600 q 0 55 -25.5 99 t -63.5 68 t -75 36.5 t -67 12.5 q -24 0 -52.5 -10 t -62.5 -32 t -65.5 -67 t -50.5 -107 L 900 -1600 l -100 -100 L 500 -1700 q -6 -46 -6 -100 L 900 -1800 l -100 -100 L 500 -1900 q 9 -74 33 -132 t 52.5 -91 t 62 -54.5 t 59 -29 t 46.5 -7.5 q 29 0 66 13 t 75 37 t 63.5 67.5 t 25.5 96.5 L 1157 -2000 q -31 -172 -128 -278 q -107 -117 -274 -117 q -205 0 -324 158 q -36 46 -69 131.5 t -45 205.5 L 100 -1900 z"/></font></defs><sodipodi:namedview/><g inkscape:label="GlyphLayer-A" inkscape:groupmode="layer"><path d="M 100 700 L 100 500 L 359 500 l -183 -183 l 141 -141 l 183 183 L 500 100 L 700 100 L 700 359 l 183 -183 l 141 141 l -183 183 L 1100 500 L 1100 700 L 841 700 l 183 183 l -141 141 l -183 -183 L 700 1100 L 500 1100 L 500 841 l -183 183 l -141 -141 l 183 -183 L 100 700 z"/></g><g inkscape:label="GlyphLayer-B" inkscape:groupmode="layer" style="display:none"><path d="M 0 800 L 0 500 L 400 500 L 400 100 L 700 100 L 700 500 L 1100 500 L 1100 800 L 700 800 L 700 1200 L 400 1200 L 400 800 L 0 800 z"/></g><g inkscape:label="GlyphLayer-C" inkscape:groupmode="layer" style="display:none"><path d="M 100 700 l 100 -100 L 313 600 q 0 -47 5 -100 L 100 500 l 100 -100 L 335 400 q 37 -167 112 -257 q 117 -141 297 -141 q 242 0 354 189 q 60 103 66 209 L 983 400 q 0 -55 -25.5 -99 t -63.5 -68 t -75 -36.5 t -67 -12.5 q -24 0 -52.5 10 t -62.5 32 t -65.5 67 t -50.5 107 L 900 400 l -100 100 L 500 500 q -6 46 -6 100 L 900 600 l -100 100 L 500 700 q 9 74 33 132 t 52.5 91 t 62 54.5 t 59 29 t 46.5 7.5 q 29 0 66 -13 t 75 -37 t 63.5 -67.5 t 25.5 -96.5 L 1157 800 q -31 172 -128 278 q -107 117 -274 117 q -205 0 -324 -158 q -36 -46 -69 -131.5 t -45 -205.5 L 100 700 z"/></g></svg>
\ No newline at end of file
......@@ -504,8 +504,8 @@ class PathTest(ElementTestCase):
path.transform = Transform(translate=(10, 10))
self.assertEqual(path.get('d'), 'M30,130 L60,130 L60,120 L70,140 L60,160 L60,150 L30,150')
path.apply_transform()
self.assertEqual(path.get('d'), 'M 30 130 L 60 130 L 60 120 '
'L 70 140 L 60 160 L 60 150 L 30 150')
self.assertEqual(path.get('d'), 'M 40 140 L 70 140 L 70 130 L 80 150 '
'L 70 170 L 70 160 L 40 160')
self.assertFalse(path.transform)
class CircleTest(ElementTestCase):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment