-
Notifications
You must be signed in to change notification settings - Fork 71
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 the Rect::overlaps
and Rect::contains_rect
methods
#347
Conversation
Rect::intersect
methodRect::overlaps
and Rect::contains_rect
methods
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this makes sense, and I've seen similar methods to these in other geom libraries.
My mistake, I completely forgot about this. I just commited the suggested modifications. |
@nils-mathieu Could you please rebase this on top of current |
Github's autosync merged rather than rebasing without asking, I hope it's okay. |
One last thing (from me): Could you add an entry to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to approve this, as the methods seem useful, but I will point out that overlaps
is a weaker predicate than the question of whether there exists a point that is inside both rectangles, as the latter is defined as x0 <= x < x1. The documentation is correct, and, while I considered another name like "overlaps_inclusive," I think that's clunky and not worth it.
Thanks for the PR and sorry for the delay.
done! |
Thanks everyone! |
I stumbled on this while toying with the
vello
rendering engine (which is great btw, you guys are doing god's work). I'm trying to create a simple audio sequencer with it and while trying to determine whether shapes were visible on screen, I found that there was no way of checking for the intersection of twoRect
s.Right now, the only way to do that is to compute their intersection, then verify whether it's empty or not.
This is not ideal for two reasons:
This pull request adds
Rect::overlaps
andRect::contains_rect
, which do exactly that.