From 60d67923b6c812ad75cfe6614297c04536b425e8 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 30 Mar 2017 01:38:27 -0700 Subject: [PATCH] fix issue#15 Path.cropped() bug, and more -also fixed .cropped(1, 0) bug (now raises AssertionError) -also now Path.cropped() raises AssertionError if given negative values --- svgpathtools/path.py | 8 +++++++- test/test_path.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/svgpathtools/path.py b/svgpathtools/path.py index ec23b71..7afd58e 100644 --- a/svgpathtools/path.py +++ b/svgpathtools/path.py @@ -2136,7 +2136,13 @@ class Path(MutableSequence): def cropped(self, T0, T1): """returns a cropped copy of the path.""" + assert 0 <= T0 <= 1 and 0 <= T1<= 1 assert T0 != T1 + assert not (T0 == 1 and T1 == 0) + + if T0 == 1 and 0 < T1 < 1 and self.isclosed(): + return self.cropped(0, T1) + if T1 == 1: seg1 = self[-1] t_seg1 = 1 @@ -2171,7 +2177,7 @@ class Path(MutableSequence): # T1