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

Hard to work with ends of simple, unclosed bezier path #20

Open
wolfmcnally opened this issue Oct 14, 2018 · 2 comments
Open

Hard to work with ends of simple, unclosed bezier path #20

wolfmcnally opened this issue Oct 14, 2018 · 2 comments
Assignees

Comments

@wolfmcnally
Copy link

wolfmcnally commented Oct 14, 2018

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:

  1. Create the polyline as a path going from the center of one box to the center of the next.
  2. Create paths for the boxes at the head and tail of the line.
  3. Subtract the paths of the boxes from the line, removing the part of the line where it intersects the boxes.
  4. 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.
  5. Outline the path and the paths for the arrowheads
  6. 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?

@hfutrell
Copy link
Owner

hfutrell commented Nov 12, 2018

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.

@hfutrell hfutrell self-assigned this Nov 12, 2018
@hfutrell
Copy link
Owner

@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.

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

2 participants