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
|
package layout
type Edges struct {
Top, Right, Bottom, Left int
}
func EdgeAll(n int) Edges {
return Edges{Top: n, Right: n, Bottom: n, Left: n}
}
func EdgeSymmetric(v, h int) Edges {
return Edges{Top: v, Right: h, Bottom: v, Left: h}
}
func EdgeTRBL(t, r, b, l int) Edges {
return Edges{Top: t, Right: r, Bottom: b, Left: l}
}
func (e Edges) Horizontal() int {
return e.Left + e.Right
}
func (e Edges) Vertical() int {
return e.Top + e.Bottom
}
func (e Edges) IsZero() bool {
return e.Top == 0 && e.Right == 0 && e.Bottom == 0 && e.Left == 0
}
|