23 lines
490 B
Go
23 lines
490 B
Go
|
package geom
|
||
|
|
||
|
// RectangleF is defined by two points, the minimum and maximum (floating point).
|
||
|
type RectangleF struct {
|
||
|
Min, Max PointF
|
||
|
}
|
||
|
|
||
|
// RectF is a shorthand function to create a rectangle.
|
||
|
func RectF(x0, y0, x1, y1 float64) RectangleF {
|
||
|
if x0 > x1 {
|
||
|
x0, x1 = x1, x0
|
||
|
}
|
||
|
if y0 > y1 {
|
||
|
y0, y1 = y1, y0
|
||
|
}
|
||
|
return RectangleF{PtF(x0, y0), PtF(x1, y1)}
|
||
|
}
|
||
|
|
||
|
// 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)
|
||
|
}
|