add Rect.Area

This commit is contained in:
faiface 2017-07-05 19:35:11 +02:00
parent 5723022b5a
commit 72a4dd03e7
1 changed files with 5 additions and 0 deletions

View File

@ -203,6 +203,11 @@ func (r Rect) Size() Vec {
return V(r.W(), r.H())
}
// Area returns the area of r. If r is not normalized, area may be negative.
func (r Rect) Area() float64 {
return r.W() * r.H()
}
// Center returns the position of the center of the Rect.
func (r Rect) Center() Vec {
return Lerp(r.Min, r.Max, 0.5)