Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

output of clipping closed paths not closed? #8

Open
lebedov opened this issue Aug 21, 2024 · 0 comments
Open

output of clipping closed paths not closed? #8

lebedov opened this issue Aug 21, 2024 · 0 comments

Comments

@lebedov
Copy link

lebedov commented Aug 21, 2024

The below code outputs a path containing the coordinates [(4., 4.), (2., 4.), (2., 2.), (4., 2)]. Not sure if I'm overlooking something obvious, but if Clipper.addPath() assumes the added path is closed by default, shouldn't the output be [(4., 4.), (2., 4.), (2., 2.), (4., 2), (4., 4.)]? Or does pyclipr just assume a line segment between the first and last coordinates of a contour? I'm puzzled because Clipper's documentation ("Paths are closed when their ends do join (with an implicit line segment between the first and last vertices)") seems to imply the latter, while the example in the pyclipr readme uses paths whose first and last coordinates are the same. I'm using pyclipr 0.1.7 on MacOS 14.6.1.

import numpy as np
import pyclr

a_contour = np.array([(0.0, 0.0), (4.0, 0.0), (4.0, 4.0), (0.0, 4.0), (0.0, 0.0)])
b_contour = np.array([(2.0, 2.0), (6.0, 2.0), (6.0, 6.0), (2.0, 6.0), (2.0, 2.0)])

pc = pyclipr.Clipper()
pc.addPath(a_contour, pyclipr.Subject)
pc.addPath(b_contour, pyclipr.Clip)

out = pc.execute(pyclipr.Intersection, pyclipr.FillRule.EvenOdd)
print(out)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant