-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathregion.go
69 lines (54 loc) · 1.2 KB
/
region.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package helios
import "time"
type Point struct {
x float64
y float64
}
func NewPoint(x, y float64) *Point {
return &Point{x, y}
}
func (p *Point) GetX() float64 {
return p.x
}
func (p *Point) GetY() float64 {
return p.y
}
type Region struct {
topLeft *Point
width int
height int
screen *Screen
finder *Finder
}
func NewRegion(topLeft *Point, width, height int, screen *Screen, finder *Finder) *Region {
return &Region{topLeft, width, height, screen, finder}
}
func (r *Region) GetTopLeft() *Point {
return r.topLeft
}
func (r *Region) GetWidth() int {
return r.width
}
func (r *Region) GetHeight() int {
return r.height
}
func (r *Region) Highlight(t time.Duration) {
r.screen.highlighter.Highlight(&HighlightRequest{
ScreenWidth: r.screen.width,
ScreenHeight: r.screen.height,
X: r.topLeft.x,
Y: r.topLeft.y,
Width: float64(r.width),
Height: float64(r.height),
Duration: t.Seconds(),
})
}
func (r *Region) Find(i *Image) *Match {
return r.screen.finder.Find(i, r)
}
func (r *Region) FindAll(i *Image) []*Match {
return r.screen.finder.FindAll(i, r)
}
func (r *Region) Wait(i *Image, t time.Duration) *Match {
return r.finder.Wait(i, r, t)
}