Hard to work with ends of simple, unclosed bezier path
wolfmcnally opened this issue · 2 comments
I very much like what you are doing with BezierKit and would like to use it for a new project. I plan to draw graphs (boxes connected by lines). The path between boxes will be connected by polylines (converted to BezierKit Paths) and I want to add arrowheads where the path intersects with the box at either end. This seems like it ought to be easy:
- Create the polyline as a path going from the center of one box to the center of the next.
- Create paths for the boxes at the head and tail of the line.
- Subtract the paths of the boxes from the line, removing the part of the line where it intersects the boxes.
- Create paths for arrowheads at the ends of the line path, using the derivative of the path at its tail and head for angles for the arrowheads.
- Outline the path and the paths for the arrowheads
- Perform a union on the path and the arrowhead paths so they can be drawn or manipulated further as a single graphics entity.
Unfortunately, I run into problems at step 3, as the boolean operations only seem to work on closed paths, and the polyline is, in its simplest case a single straight line segment— it might be composed of many segments or other bezier curves, but it is not a closed path. If I first outline the path, the subtraction works as expected, but then I can't simply compute the locations of the path's ends and derivatives to know where to place the arrowheads. I can compute the intersections of the box paths with the line paths, but there doesn't appear to be any way to simply use the PathIntersection
or IndexedPathLocation
objects to split the path at the intersection points.
As I said, this seems like it ought to be easy. Am I missing something?
Hi @wolfmcnally. Sorry for the late response ... Github didn't notify me when the issue was opened (hopefully it will in the future after I updated my preferences).
You are correct that the boolean operations only work on closed paths. I'm still working on getting the boolean operations to work properly on all closed paths so it's unlikely that I'll get it to work on open paths any time soon (boolean operations are the most difficult part of the API).
I'll take a look at finding a way to let you use IndexedPathLocation to achieve what you want. It's designed to handle this sort of thing, you're just the first to request it.
@wolfmcnally I noticed you've forked BezierKit to add a Path.split method. Is that working for you? If it's not I can try to add support for open paths in boolean operations (to allow your step 3 to succeed) in the next release.