-
Notifications
You must be signed in to change notification settings - Fork 0
/
guides.go
120 lines (99 loc) · 1.97 KB
/
guides.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
package counters
import (
"image"
"github.com/fogleman/gg"
)
func DrawGuides(s *Settings) (*image.Image, error) {
var p Positioner
width := float64(s.Width)
height := float64(s.Height)
temp := gg.NewContext(s.Width, s.Height)
temp.SetRGBA(1, 0, 0, 0.6)
//Vertical
x, _, err := p.GetXYPosition(2, s)
if err != nil {
return nil, err
}
temp.DrawLine(x, 0, x, height)
temp.Stroke()
x, _, err = p.GetXYPosition(4, s)
if err != nil {
return nil, err
}
temp.DrawLine(x, 0, x, height)
temp.Stroke()
//Horizontal
_, y, err := p.GetXYPosition(16, s)
if err != nil {
return nil, err
}
temp.DrawLine(0, y, width, y)
temp.Stroke()
_, y, err = p.GetXYPosition(14, s)
if err != nil {
return nil, err
}
temp.DrawLine(0, y, width, y)
temp.Stroke()
//Horizontal center
x, _, err = p.GetXYPosition(0, s)
if err != nil {
return nil, err
}
temp.SetRGBA(0, 0, 1, 0.6)
temp.DrawLine(x, 0, x, height)
temp.Stroke()
// Vertical center
_, y, err = p.GetXYPosition(0, s)
if err != nil {
return nil, err
}
temp.DrawLine(0, y, width, y)
temp.Stroke()
temp.SetRGBA(0, 1, 1, 0.8)
//Horizontal margins
x1, y1, err := p.GetXYPosition(1, s)
if err != nil {
return nil, err
}
x2, y2, err := p.GetXYPosition(5, s)
if err != nil {
return nil, err
}
temp.DrawLine(x1, y1, x2, y2)
temp.Stroke()
x1, y1, err = p.GetXYPosition(13, s)
if err != nil {
return nil, err
}
x2, y2, err = p.GetXYPosition(9, s)
if err != nil {
return nil, err
}
temp.DrawLine(x1, y1, x2, y2)
temp.Stroke()
//Vertical margins
x1, y1, err = p.GetXYPosition(1, s)
if err != nil {
return nil, err
}
x2, y2, err = p.GetXYPosition(13, s)
if err != nil {
return nil, err
}
temp.DrawLine(x1, y1, x2, y2)
temp.Stroke()
x1, y1, err = p.GetXYPosition(5, s)
if err != nil {
return nil, err
}
x2, y2, err = p.GetXYPosition(9, s)
if err != nil {
return nil, err
}
temp.DrawLine(x1, y1, x2, y2)
temp.Stroke()
temp.SetRGB(0, 0, 0)
img := temp.Image()
return &img, nil
}