-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathshapeLinearPath.go
More file actions
51 lines (40 loc) · 955 Bytes
/
shapeLinearPath.go
File metadata and controls
51 lines (40 loc) · 955 Bytes
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
package gorough
import (
"github.com/NovikovRoman/gorough/data_parser"
)
type linearPath struct {
options *LineOptions
operations []operation
}
func (l linearPath) Name() string {
return shapeLinearPath
}
func (l linearPath) Operations() []operation {
return l.operations
}
func (l linearPath) Attributes() Attributes {
return map[string]string{
"stroke": l.options.Styles.Stroke,
"stroke-width": data_parser.FloatToString(l.options.Styles.StrokeWidth),
}
}
func (l linearPath) Styles() *Styles {
return l.options.Styles
}
func NewLinearPath(points []Point, opt *LineOptions) *linearPath {
if opt == nil {
opt = &LineOptions{}
}
if opt.PenOptions == nil {
opt.PenOptions = PenOptionsDefault()
}
if opt.Styles == nil {
opt.Styles = StylesDefault()
}
opt.Styles.canonicalValues()
l := &linearPath{
options: opt,
operations: []operation{linearPathOperation(points, false, opt.PenOptions)},
}
return l
}