1
0
mirror of https://github.com/golang/go synced 2024-11-20 04:14:49 -07:00

Fix Rectangle.Canon()

R=rsc, r, gri
CC=golang-dev
https://golang.org/cl/1239043
This commit is contained in:
Roger Peppe 2010-05-20 14:33:50 -07:00 committed by Robert Griesemer
parent efda3aba10
commit 798140693e

View File

@ -59,10 +59,10 @@ func (r Rectangle) Sub(p Point) Rectangle { return Rectangle{r.Min.Sub(p), r.Max
// has Min.X <= Max.X and Min.Y <= Max.Y.
func (r Rectangle) Canon() Rectangle {
if r.Max.X < r.Min.X {
r.Max.X = r.Min.X
r.Min.X, r.Max.X = r.Max.X, r.Min.X
}
if r.Max.Y < r.Min.Y {
r.Max.Y = r.Min.Y
r.Min.Y, r.Max.Y = r.Max.Y, r.Min.Y
}
return r
}