summaryrefslogtreecommitdiff
path: root/lib/elements/stroke.py
diff options
context:
space:
mode:
authorKaalleen <36401965+kaalleen@users.noreply.github.com>2024-11-12 19:07:24 +0100
committerGitHub <noreply@github.com>2024-11-12 19:07:24 +0100
commit45dda2616d4d636759136e2c65998670ea06855c (patch)
tree0dd33c7ab51cb69b0b6128df0095c5f84e876f2b /lib/elements/stroke.py
parent7c99a138d12bcd5f9f4cdbfd3ff7c2b15ec890e4 (diff)
Clipped groups (#3261)
Diffstat (limited to 'lib/elements/stroke.py')
-rw-r--r--lib/elements/stroke.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/elements/stroke.py b/lib/elements/stroke.py
index 925a7dcd..d41d74db 100644
--- a/lib/elements/stroke.py
+++ b/lib/elements/stroke.py
@@ -423,9 +423,19 @@ class Stroke(EmbroideryElement):
@property
def paths(self):
+ return self._get_paths()
+
+ @property
+ def unclipped_paths(self):
+ return self._get_paths(False)
+
+ def _get_paths(self, clipped=True):
path = self.parse_path()
flattened = self.flatten(path)
- flattened = self._get_clipped_path(flattened)
+ if clipped:
+ flattened = self._get_clipped_path(flattened)
+ if flattened is None:
+ return []
# manipulate invalid path
if len(flattened[0]) == 1:
@@ -447,10 +457,10 @@ class Stroke(EmbroideryElement):
return shgeo.MultiLineString(line_strings)
def _get_clipped_path(self, paths):
- if self.node.clip is None:
+ clip_path = get_clip_path(self.node)
+ if clip_path is None:
return paths
- clip_path = get_clip_path(self.node)
# path to linestrings
line_strings = [shgeo.LineString(path) for path in paths]
try:
@@ -460,7 +470,7 @@ class Stroke(EmbroideryElement):
coords = []
if intersection.is_empty:
- return paths
+ return None
elif isinstance(intersection, shgeo.MultiLineString):
for c in [intersection for intersection in intersection.geoms if isinstance(intersection, shgeo.LineString)]:
coords.append(c.coords)