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

image: Rectangle.{Overlaps,Intersect} doesn't check for 1 pixel overlaps #8695

Closed
OneOfOne opened this issue Sep 10, 2014 · 2 comments
Closed

Comments

@OneOfOne
Copy link
Contributor

Overlaps and Intersect should use >= / <= for their checks.

func (r Rectangle) Overlaps(s Rectangle) bool {
    return r.Min.X <= s.Max.X && s.Min.X <= r.Max.X &&
        r.Min.Y <= s.Max.Y && s.Min.Y <= r.Max.Y
}

instead of 

func (r Rectangle) Overlaps(s Rectangle) bool {
    return r.Min.X < s.Max.X && s.Min.X < r.Max.X &&
        r.Min.Y < s.Max.Y && s.Min.Y < r.Max.Y
}
@ianlancetaylor
Copy link
Contributor

Comment 1:

Labels changed: added repo-main, release-none.

@nigeltao
Copy link
Contributor

Comment 2:

As the documentation at http://golang.org/pkg/image/#Rectangle says, a Rectangle is
inclusive (<=) on the Min end but exclusive (<) on the Max end. Overlaps should
use < and not <=.

Status changed to WorkingAsIntended.

@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants