/
options.go
57 lines (45 loc) · 898 Bytes
/
options.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
package imagecat
import "image/draw"
type Axis int
type Alignment int
const (
// Specifies the axis with which the images will be concatenated on
AxisX Axis = iota
AxisY
// Specifies the alignment that will be applied to the images
AlignmentStart Alignment = iota
AlignmentCenter
AlignmentEnd
)
type config struct {
axis Axis
alignment Alignment
op draw.Op
}
func newConfig(options ...OptionFn) *config {
cfg := &config{
axis: AxisX,
alignment: AlignmentStart,
op: draw.Over,
}
for _, option := range options {
option(cfg)
}
return cfg
}
type OptionFn func(*config)
func WithAxis(axis Axis) OptionFn {
return func(c *config) {
c.axis = axis
}
}
func WithAlignment(alignment Alignment) OptionFn {
return func(c *config) {
c.alignment = alignment
}
}
func WithDrawOp(op draw.Op) OptionFn {
return func(c *config) {
c.op = op
}
}