Added function to create a Line

This commit is contained in:
Ben Cragg 2019-04-01 15:37:23 +01:00
parent 1eac5d8dc2
commit 128ec4d4c0
1 changed files with 8 additions and 0 deletions

View File

@ -186,6 +186,14 @@ type Line struct {
A, B Vec
}
// L creates and returns a new Line object.
func L(from, to Vec) Line {
return Line{
A: from,
B: to,
}
}
// Bounds returns the lines bounding box. This is in the form of a normalized `Rect`.
func (l Line) Bounds() Rect {
return R(l.A.X, l.A.Y, l.B.X, l.B.Y).Norm()