Added methods to calculate width & height for RectangleF.

This commit is contained in:
Sander Schobers 2017-11-01 11:24:33 +01:00
parent e181615d9e
commit cac351f290

View File

@ -16,7 +16,17 @@ func RectF(x0, y0, x1, y1 float64) RectangleF {
return RectangleF{PtF(x0, y0), PtF(x1, y1)}
}
// Dx returns the width of r.
func (r RectangleF) Dx() float64 {
return r.Max.X - r.Min.X
}
// Dy returns the height of r.
func (r RectangleF) Dy() float64 {
return r.Max.Y - r.Min.Y
}
// Size returns the size of the rectangle.
func (r RectangleF) Size() PointF {
return PtF(r.Max.X-r.Min.X, r.Max.Y-r.Min.Y)
return PointF{r.Max.X - r.Min.X, r.Max.Y - r.Min.Y}
}