From 72a4dd03e73d7cf6fb498b73bdd051a0eb5ea72f Mon Sep 17 00:00:00 2001 From: faiface Date: Wed, 5 Jul 2017 19:35:11 +0200 Subject: [PATCH] add Rect.Area --- geometry.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/geometry.go b/geometry.go index 503d8cb..56283a9 100644 --- a/geometry.go +++ b/geometry.go @@ -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)