-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathshapeCircle.go
More file actions
56 lines (45 loc) · 1.1 KB
/
shapeCircle.go
File metadata and controls
56 lines (45 loc) · 1.1 KB
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
package gorough
import (
"github.com/NovikovRoman/gorough/data_parser"
)
type circle struct {
options *EllipseOptions
operations []operation
}
func (c circle) Name() string {
return shapeEllipse
}
func (c circle) Operations() []operation {
return c.operations
}
func (c circle) Attributes() Attributes {
return map[string]string{
"stroke": c.options.Styles.Stroke,
"stroke-width": data_parser.FloatToString(c.options.Styles.StrokeWidth),
"fill": c.options.Styles.Fill,
"fill-weight": data_parser.FloatToString(c.options.Styles.FillWeight),
}
}
func (c circle) Styles() *Styles {
return c.options.Styles
}
func NewCircle(center Point, diameter float64, opt *EllipseOptions) *circle {
if opt == nil {
opt = &EllipseOptions{}
}
if opt.PenOptions == nil {
opt.PenOptions = PenOptionsDefault()
}
if opt.CurveOptions == nil {
opt.CurveOptions = CurveOptionsDefault()
}
if opt.Styles == nil {
opt.Styles = StylesDefault()
}
opt.Styles.canonicalValues()
c := &circle{
options: opt,
operations: ellipseOperations(center, diameter, diameter, opt),
}
return c
}