rename bounds to rect
parent
e7471df15a
commit
3f657da4cd
@ -1,22 +1,22 @@
|
|||||||
package math
|
package math
|
||||||
|
|
||||||
type Bounds struct {
|
type Rect struct {
|
||||||
Origin Vec `json:"origin"`
|
Origin Vec `json:"origin"`
|
||||||
Width int `json:"width"`
|
Width int `json:"width"`
|
||||||
Height int `json:"height"`
|
Height int `json:"height"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateBounds(width, height int) Bounds {
|
func CreateRect(width, height int) Rect {
|
||||||
return Bounds{
|
return Rect{
|
||||||
Origin: Vec{0, 0},
|
Origin: Vec{0, 0},
|
||||||
Width: width,
|
Width: width,
|
||||||
Height: height,
|
Height: height,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b Bounds) Area() int { return b.Width * b.Height }
|
func (b Rect) Area() int { return b.Width * b.Height }
|
||||||
|
|
||||||
func (b Bounds) Contains(v Vec) bool {
|
func (b Rect) Contains(v Vec) bool {
|
||||||
return v.X >= b.Origin.X &&
|
return v.X >= b.Origin.X &&
|
||||||
v.X < b.Origin.X+b.Width &&
|
v.X < b.Origin.X+b.Width &&
|
||||||
v.Y >= b.Origin.Y &&
|
v.Y >= b.Origin.Y &&
|
Loading…
Reference in New Issue