add Rect.Union
This commit is contained in:
parent
3d3cbd6027
commit
e9a3c900cf
10
geometry.go
10
geometry.go
|
@ -272,6 +272,16 @@ func (r Rect) Contains(u Vec) bool {
|
||||||
return r.Min.X() <= u.X() && u.X() <= r.Max.X() && r.Min.Y() <= u.Y() && u.Y() <= r.Max.Y()
|
return r.Min.X() <= u.X() && u.X() <= r.Max.X() && r.Min.Y() <= u.Y() && u.Y() <= r.Max.Y()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Union returns a minimal Rect which covers both r and s. Rects r and s should be normalized.
|
||||||
|
func (r Rect) Union(s Rect) Rect {
|
||||||
|
return R(
|
||||||
|
math.Min(r.Min.X(), s.Min.X()),
|
||||||
|
math.Min(r.Min.Y(), s.Min.Y()),
|
||||||
|
math.Max(r.Max.X(), s.Max.X()),
|
||||||
|
math.Max(r.Max.Y(), s.Max.Y()),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// Matrix is a 3x3 transformation matrix that can be used for all kinds of spacial transforms, such
|
// Matrix is a 3x3 transformation matrix that can be used for all kinds of spacial transforms, such
|
||||||
// as movement, scaling and rotations.
|
// as movement, scaling and rotations.
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue