some refinement and beginning of a table element
This commit is contained in:
10
common/geo/bounds.go
Normal file
10
common/geo/bounds.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package geo
|
||||
|
||||
type Bounds struct {
|
||||
Min Point
|
||||
Width, Height int
|
||||
}
|
||||
|
||||
func (b *Bounds) Contains(p Point) bool {
|
||||
return p.X >= b.Min.X && p.X <= b.Min.X+b.Width && p.Y >= b.Min.Y && p.Y <= b.Min.Y+b.Height
|
||||
}
|
||||
19
common/geo/point.go
Normal file
19
common/geo/point.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package geo
|
||||
|
||||
type Point struct {
|
||||
X, Y int
|
||||
}
|
||||
|
||||
func (p Point) Delta(p2 Point) Point {
|
||||
return Point{
|
||||
X: p2.X - p.X,
|
||||
Y: p2.Y - p.Y,
|
||||
}
|
||||
}
|
||||
|
||||
func (p Point) Add(p2 Point) Point {
|
||||
return Point{
|
||||
X: p.X + p2.X,
|
||||
Y: p.Y + p2.Y,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user