mirror of
https://github.com/golang/go
synced 2024-11-19 04:14:45 -07:00
Revert "image: fix the overlap check in Rectangle.Intersect."
This reverts commit a855da29db
.
Change-Id: I23c0351b0708877e0b3d1b44a2bc2799cee52cd1
Reviewed-on: https://go-review.googlesource.com/36426
Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
parent
50c7783f59
commit
14347ee480
@ -161,11 +161,7 @@ func (r Rectangle) Intersect(s Rectangle) Rectangle {
|
|||||||
if r.Max.Y > s.Max.Y {
|
if r.Max.Y > s.Max.Y {
|
||||||
r.Max.Y = s.Max.Y
|
r.Max.Y = s.Max.Y
|
||||||
}
|
}
|
||||||
// Letting r0 and s0 be the values of r and s at the time that the method
|
if r.Min.X > r.Max.X || r.Min.Y > r.Max.Y {
|
||||||
// is called, this next line is equivalent to:
|
|
||||||
//
|
|
||||||
// if max(r0.Min.X, s0.Min.X) >= min(r0.Max.X, s0.Max.X) || likewiseForY { etc }
|
|
||||||
if r.Empty() {
|
|
||||||
return ZR
|
return ZR
|
||||||
}
|
}
|
||||||
return r
|
return r
|
||||||
|
@ -28,7 +28,6 @@ func TestRectangle(t *testing.T) {
|
|||||||
|
|
||||||
rects := []Rectangle{
|
rects := []Rectangle{
|
||||||
Rect(0, 0, 10, 10),
|
Rect(0, 0, 10, 10),
|
||||||
Rect(10, 0, 20, 10),
|
|
||||||
Rect(1, 2, 3, 4),
|
Rect(1, 2, 3, 4),
|
||||||
Rect(4, 6, 10, 10),
|
Rect(4, 6, 10, 10),
|
||||||
Rect(2, 3, 12, 5),
|
Rect(2, 3, 12, 5),
|
||||||
@ -63,9 +62,9 @@ func TestRectangle(t *testing.T) {
|
|||||||
if err := in(a, s); err != nil {
|
if err := in(a, s); err != nil {
|
||||||
t.Errorf("Intersect: r=%s, s=%s, a=%s, a not in s: %v", r, s, a, err)
|
t.Errorf("Intersect: r=%s, s=%s, a=%s, a not in s: %v", r, s, a, err)
|
||||||
}
|
}
|
||||||
if isZero, overlaps := a == (Rectangle{}), r.Overlaps(s); isZero == overlaps {
|
if a.Empty() == r.Overlaps(s) {
|
||||||
t.Errorf("Intersect: r=%s, s=%s, a=%s: isZero=%t same as overlaps=%t",
|
t.Errorf("Intersect: r=%s, s=%s, a=%s: empty=%t same as overlaps=%t",
|
||||||
r, s, a, isZero, overlaps)
|
r, s, a, a.Empty(), r.Overlaps(s))
|
||||||
}
|
}
|
||||||
largerThanA := [4]Rectangle{a, a, a, a}
|
largerThanA := [4]Rectangle{a, a, a, a}
|
||||||
largerThanA[0].Min.X--
|
largerThanA[0].Min.X--
|
||||||
|
Loading…
Reference in New Issue
Block a user