From c799b798bc01ac9fc307a1dbc3c1ae68f1224669 Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Wed, 10 May 2023 09:02:47 +0200 Subject: apply clip to stroke (#2283) --- lib/svg/clip.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 lib/svg/clip.py (limited to 'lib/svg') 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:])]) -- cgit v1.2.3