diff --git a/inkex/paths.py b/inkex/paths.py index 0c5d7855ec8a0dbed18a2623817e2bd7a576bcae..1d7e61d664f6fb3bbddf1b8312a3cc4f7d70a9f6 100644 --- a/inkex/paths.py +++ b/inkex/paths.py @@ -1222,11 +1222,12 @@ class Path(list): result = Path() previous = Vector2d() previous_new = Vector2d() + start_zone = True first = Vector2d() first_new = Vector2d() for i, seg in enumerate(self): # type: PathCommand - if i == 0: + if start_zone: first = seg.end_point(first, previous) if isinstance(seg, (horz, Horz, Vert, vert)): @@ -1237,7 +1238,7 @@ class Path(list): else: new_seg = seg.transform(transform) - if i == 0: + if start_zone: first_new = new_seg.end_point(first_new, previous_new) if inplace: @@ -1246,6 +1247,7 @@ class Path(list): result.append(new_seg) previous = seg.end_point(first, previous) previous_new = new_seg.end_point(first_new, previous_new) + start_zone = isinstance(seg, (zoneClose, ZoneClose)) if inplace: return self return result diff --git a/tests/test_inkex_paths.py b/tests/test_inkex_paths.py index d046e0ae5c15df757de59a2d26cbdeff499c0ddf..64dc36c82f1b546bbe17e003c3feb3579f4df8a8 100644 --- a/tests/test_inkex_paths.py +++ b/tests/test_inkex_paths.py @@ -324,6 +324,11 @@ class PathTest(TestCase): ret = Path('M 10,10 l 10,10 Z l 10,10').scale(2, 2) self._assertPath(ret, 'M 20 20 l 20 20 Z l 20 20') + def test_scale_multiple_zones(self): + """Zone close returns current position to start of zone (not start of path)""" + ret = Path("M 100 100 Z M 200 200 Z h 0").scale(1, 1) + self._assertPath(ret.to_absolute(), "M 100 100 Z M 200 200 Z L 200 200") + def test_absolute(self): """Paths can be converted to absolute""" ret = Path("M 100 100 l 10 10 10 10 10 10") @@ -342,7 +347,6 @@ class PathTest(TestCase): ret= Path("m 1 2 h 2 v 1 z m 4 0 h 2 v 1 z m 0 2 h 2 v 1 z") self._assertPath(ret.to_absolute(), "M 1 2 H 3 V 3 Z M 5 2 H 7 V 3 Z M 5 4 H 7 V 5 Z") - def test_relative(self): """Paths can be converted to relative""" ret = Path("M 100 100 L 110 120 140 140 300 300")