forked from sclevine/agouti
/
offset.go
52 lines (39 loc) · 792 Bytes
/
offset.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
package api
type Offset interface {
x() (x int, present bool)
y() (y int, present bool)
position() (x int, y int)
}
type XYOffset struct {
X int
Y int
}
func (o XYOffset) x() (x int, present bool) {
return o.X, true
}
func (o XYOffset) y() (y int, present bool) {
return o.Y, true
}
func (o XYOffset) position() (x int, y int) {
return o.X, o.Y
}
type XOffset int
func (o XOffset) x() (x int, present bool) {
return int(o), true
}
func (XOffset) y() (y int, present bool) {
return 0, false
}
func (o XOffset) position() (x int, y int) {
return int(o), 0
}
type YOffset int
func (YOffset) x() (x int, present bool) {
return 0, false
}
func (o YOffset) y() (y int, present bool) {
return int(o), true
}
func (o YOffset) position() (x int, y int) {
return 0, int(o)
}