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

Add a methods to compute the bounding rect of quadratic and cubic bezier curves #48

Closed
nical opened this issue May 27, 2017 · 3 comments
Labels

Comments

@nical
Copy link
Owner

nical commented May 27, 2017

We first need to reexport euclid's rectangle type (euclid::Rect<T>) in bezier/src/lib.rs the same way we reexport the Point type, and add a method:

fn bounding_rect(&self) -> Rect

To QuadraticBezierSegment and CubicBezierSegment.

@nical
Copy link
Owner Author

nical commented May 27, 2017

cc @o0Ignition0o

@nical
Copy link
Owner Author

nical commented May 27, 2017

After a discussion with @o0Ignition0o, I like his suggestion to compute the minimum bounding rect, so I suggest having two methods:

fn bounding_rect(&self) -> Rect

which is a naive implementation that returns the minimum rectangle containing the control points of the curve, and

fn minimum_bounding_rect(&self) -> Rect

Which is slightly more expensive but returns a tighter rect. find_y_inflection should be useful for this, and for some reason find_x_inflection is missing but it could be added. find_y_maximum is also relevant, but find_x_maximum, find_x_minimum and find_y_minimum are missing too (should not be hard to add the missing methods taking inspiration from the existing ones).

@o0Ignition0o
Copy link
Contributor

This looks good, I'll give it a try ! I'm also considering rotating the curve to "flatten" the start and end points, before invoking find_y_maximum. I don't know if it would be the fastest implementation to get the minimum_bounding_rect, but I'll make a pr and see if I can improve it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants