You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
443 B
Go
25 lines
443 B
Go
package math
|
|
|
|
type Bounds struct {
|
|
Origin Vec `json:"origin"`
|
|
Width int `json:"width"`
|
|
Height int `json:"height"`
|
|
}
|
|
|
|
func CreateBounds(width, height int) Bounds {
|
|
return Bounds{
|
|
Origin: Vec{0, 0},
|
|
Width: width,
|
|
Height: height,
|
|
}
|
|
}
|
|
|
|
func (b Bounds) Area() int { return b.Width * b.Height }
|
|
|
|
func (b Bounds) Contains(v Vec) bool {
|
|
return v.X >= b.Origin.X &&
|
|
v.X < b.Origin.X+b.Width &&
|
|
v.Y >= b.Origin.Y &&
|
|
v.Y < b.Height
|
|
}
|