summaryrefslogtreecommitdiff
path: root/lib/svg/clip.py
diff options
context:
space:
mode:
authorKaalleen <36401965+kaalleen@users.noreply.github.com>2023-05-10 09:02:47 +0200
committerGitHub <noreply@github.com>2023-05-10 09:02:47 +0200
commitc799b798bc01ac9fc307a1dbc3c1ae68f1224669 (patch)
tree791955fd75f8f93f8a1cb66c82cc29d0600aaf86 /lib/svg/clip.py
parent9d5cc6013ef769718b47d64a558df7e4210505d1 (diff)
apply clip to stroke (#2283)
Diffstat (limited to 'lib/svg/clip.py')
-rw-r--r--lib/svg/clip.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/svg/clip.py b/lib/svg/clip.py
new file mode 100644
index 00000000..36c73947
--- /dev/null
+++ b/lib/svg/clip.py
@@ -0,0 +1,18 @@
+# Authors: see git history
+#
+# Copyright (c) 2023 Authors
+# Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details.
+
+from shapely.geometry import MultiPolygon, Polygon
+
+from ..elements import EmbroideryElement
+
+
+def get_clip_path(node):
+ # get clip and apply node transform
+ clip = node.clip
+ transform = node.composed_transform()
+ clip.transform = transform
+ clip_element = EmbroideryElement(clip)
+ clip_element.paths.sort(key=lambda point_list: Polygon(point_list).area, reverse=True)
+ return MultiPolygon([(clip_element.paths[0], clip_element.paths[1:])])