From 40cd9903f6fa5997ebef8ac8e207bdc4de1eba6d Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Tue, 5 Apr 2022 18:19:57 -0700 Subject: [PATCH] add difference_evenodd --- snarled/clipper.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/snarled/clipper.py b/snarled/clipper.py index d7dc734..f6ba60a 100644 --- a/snarled/clipper.py +++ b/snarled/clipper.py @@ -41,6 +41,20 @@ def intersection_evenodd( return pc.Execute(CT_INTERSECTION, PFT_EVENODD, PFT_EVENODD) +def difference_evenodd( + subject_shapes: Sequence[ArrayLike], + clip_shapes: Sequence[ArrayLike], + ) -> List[contour_t]: + if not subject_shapes: + return [] + if not clip_shapes: + return subject_shapes + pc = Pyclipper() + pc.AddPaths(subject_shapes, PT_SUBJECT, closed=True) + pc.AddPaths(clip_shapes, PT_CLIP, closed=True) + return pc.Execute(CT_DIFFERENCE, PFT_EVENODD, PFT_EVENODD) + + def hier2oriented(polys: Sequence[PyPolyNode]) -> List[ArrayLike]: contours = [] for poly in polys: