summaryrefslogtreecommitdiff
path: root/lib/elements/stroke.py
diff options
context:
space:
mode:
authorLex Neva <github.com@lexneva.name>2019-07-04 17:20:31 -0400
committerLex Neva <github.com@lexneva.name>2019-07-04 17:22:46 -0400
commitbec33656ece737e134ca4b7ec2dc9a7dc9c71fd1 (patch)
treeae79a6bb9af415aa9634d34b752f6d12868b1b4b /lib/elements/stroke.py
parent3ef2ad9be4173d5c154b3ba0ea39439fb2a274d8 (diff)
add trim commands in import and stitch plan
Diffstat (limited to 'lib/elements/stroke.py')
-rw-r--r--lib/elements/stroke.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/elements/stroke.py b/lib/elements/stroke.py
index 3ae2b143..e0a0aacc 100644
--- a/lib/elements/stroke.py
+++ b/lib/elements/stroke.py
@@ -1,11 +1,13 @@
import sys
+
import shapely.geometry
-from .element import param, EmbroideryElement, Patch
from ..i18n import _
-from ..utils import cache, Point
from ..stitches import running_stitch, bean_stitch
from ..svg import parse_length_with_units
+from ..utils import cache, Point
+from .element import param, EmbroideryElement, Patch
+
warned_about_legacy_running_stitch = False
@@ -85,7 +87,11 @@ class Stroke(EmbroideryElement):
@cache
def shape(self):
line_strings = [shapely.geometry.LineString(path) for path in self.paths]
- return shapely.geometry.MultiLineString(line_strings)
+
+ # Using convex_hull here is an important optimization. Otherwise
+ # complex paths cause operations on the shape to take a long time.
+ # This especially happens when importing machine embroidery files.
+ return shapely.geometry.MultiLineString(line_strings).convex_hull
@property
@param('manual_stitch',