Closed Pomax closed 8 years ago
and right after filing that I notice there are no z
statements in the sub paths... so that might be a problem.
totally the issue. Closing.
Oh, so it was happening because the paths were open? That should be handled differently in the library still, i think?
I guess that depends on whether it should treat paths as closed when it performs the boolean operation. It might make sense to force-close paths if unite/intersection etc. are called, since those operations have technically no meaning on open paths.
Yeah... Or we could define what is supposed to happen, e.g. intersecting a closed path with an open path could split the open path along the intersections and erase the bits that lie outside the closed path. This would actually be very useful for hatching and such, and not hard to implement at all... subtract()
would do the opposite of that (remove the bits that are inside the closed path). All other operations wouldn't be defined and should probably throw an error. The same is true for all operations when performing them with a closed path on the left and an open path on the right hand side.
that would be pretty cool, now that you describe it.
Here an example that then should work as described above:
hm, given the result in that sketch, I'm not sure I could explain why it'd look that way.
Don't worry that's the old code. Things have improved hugely in the Boolean ops since then. I've just put it here for reference as I'm going to implement the behavior for open paths outlined above.
A new release is imminent now. Finally!
I've updated the linked sketch above. With the latest commits in place, here is how the result now looks. The open path (blue) is intersected with a closed path (red). The result is a group of separate paths (the diagonal lines inside the rectangle), which are then joined to one zig-zag line (green). Works like a charm now!
Incredible work guys! Wahoo!
aha! The above link still shows a slightly different capping for me, which could be because of the specific paper.js it's referencing?
That's because Sketch is still running the old version of the library. I need to update it!
Try again now, with force refresh!
Force refresh was the ticket for me, works great!
That's pretty sweet @lehni =)
Please note that in order to get this open path / stroke-based behavior, you now need to call it like this:
var res = line.intersect(rect, { stroke: true });
The following code has some interesting, and wrong, union behaviour:
result: