add Rect.Size

This commit is contained in:
faiface 2017-03-14 18:25:39 +01:00
parent be276888f6
commit c81dedd9a1
1 changed files with 5 additions and 0 deletions

View File

@ -182,6 +182,11 @@ func (r Rect) H() float64 {
return r.Max.Y() - r.Min.Y()
}
// Size returns the vector of width and height as components respectively.
func (r Rect) Size() Vec {
return V(r.W(), r.H())
}
// Center returns the position of the center of the rectangle.
func (r Rect) Center() Vec {
return (r.Min + r.Max) / 2