-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstructs.go
77 lines (65 loc) · 1.11 KB
/
structs.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
package gopie
import "math"
type style struct {
Fill string
StrokeWidth float64
StrokeColor string
}
type slice struct {
ChartID string
ID int
Path string
Style style
}
type circle struct {
ChartID string
CenterX float64
CenterY float64
Radius float64
Style style
}
type line struct {
X1 float64
Y1 float64
X2 float64
Y2 float64
Style style
}
type text struct {
Text string
X float64
Y float64
FontSize float64
FontFamily string
FontAnchor string
}
type chart struct {
Width float64
Height float64
Pie *pie
Donut *donut
Labels []label
NeedsMasking bool
EmbedFont bool
Font fontDetails
}
type fontDetails struct {
FontFamily string
Base64 string
}
type label struct {
Text text
Line line
}
type rectangle struct {
Left float64
Top float64
Width float64
Height float64
}
func (r rectangle) getCenter() (centerX, centerY float64) {
return r.Left + r.Width/2, r.Top + r.Height/2
}
func (r rectangle) calculateIncircleRadius() float64 {
return math.Min(r.Height, r.Width) / 2
}