-
Notifications
You must be signed in to change notification settings - Fork 14
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
[question] Would Skia PathOps in principle able to do subtraction _without_ implying "union" on the subject? #74
Comments
I see what you mean, but it's not us (python bindings) who are doing that, we are just calling the Skia PathOps C++ API ( |
I know that, but to ask a question to the Skia library community is a way higher threshold... A long shot, for sure. |
Thank you for your response! |
no worries.. Yeah I know. Skia is a bit of a black box for us too 😅 Are you perhaps using OpBuilder? Maybe you could try using the alternative |
Interesting! I will try to study and understand that, thanks. |
I mean this: skia-pathops/src/python/pathops/_pathops.pyx Line 1552 in 815070e
like used in here for the binary
|
We're indeed using OpBuilder. Thanks for the pointer! Will report back. |
in theory they should produce the same output, OpBuilder being more efficient when one wants to apply a chain of path operations, as opposed to just one Op between two sets of 'subject' and 'clip' contours. |
It would also be interesting to see what booleanOperations do in this case. I tried to design skia-pathops interface to be a drop-in replacement for booleanOperations (in fact ufo2ft can select one or the other). The binary ops (difference, intersection, reverse_difference, xor) take two lists of contours respectively for subject and clip ('contours' are any objects with a draw(pen) method), whereas union only takes a single list. All operations also take a pen to output the result. |
I've tried with booleanOperations in DrawBot, and it also seems to remove overlaps. |
I've tried with the raw "op" method instead of OpBuilder: no difference. |
hm well it was worth a try. I don't think booleanOperations attempts to simplify the contours before processing the binary operations, so if that occurs it must be happening in the underlying Clipper library. Maybe it is in fact necessary for the algorithm to work. |
good point. Seems like a hard problem and I'm afraid I don't have a solution right now. |
Thanks for thinking along. I posted a feature request for the future Kurbo path operations feature :) |
good idea! This looks beyond my pay-grade but possibly within Raph's :) I think at least for the case of multiple mutually overlapping subject contours (as in the screenshot) one may perform the difference operation using the same clip path for each distinct subject contour (as opposed to a group of subjects ) such that they will continue to stay distict instead of being merged with one another. However for a single self-overlapping subject contour, that would not work. |
I think at least for Skia, it doesn't care about keeping overlapping paths since it's a rendering library. The path simplification step that it does first probably simplifies the subsequent boolean op logic. |
Before:
After subtracting the selected shape from the rest:
It would be nice if it were possible to keep the overlaps in the subject shape.
The text was updated successfully, but these errors were encountered: