-
Notifications
You must be signed in to change notification settings - Fork 0
/
attr_stroke_join_style.go
65 lines (52 loc) · 1.42 KB
/
attr_stroke_join_style.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
// Copyright (c) 2017 Andrey Gayvoronsky <plandem@gmail.com>
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package vml
import (
"encoding/xml"
)
//StrokeJoinStyle is direct mapping of ST_StrokeJoinStyle
type StrokeJoinStyle byte
var (
toStrokeJoinStyle map[string]StrokeJoinStyle
fromStrokeJoinStyle map[StrokeJoinStyle]string
)
//List of all possible values for StrokeJoinStyle
const (
_ StrokeJoinStyle = iota
StrokeJoinStyleRound
StrokeJoinStyleBevel
StrokeJoinStyleMiter
)
func init() {
fromStrokeJoinStyle = map[StrokeJoinStyle]string{
StrokeJoinStyleRound: "round",
StrokeJoinStyleBevel: "bevel",
StrokeJoinStyleMiter: "miter",
}
toStrokeJoinStyle = make(map[string]StrokeJoinStyle, len(fromStrokeJoinStyle))
for k, v := range fromStrokeJoinStyle {
toStrokeJoinStyle[v] = k
}
}
//String returns string presentation of StrokeJoinStyle
func (t StrokeJoinStyle) String() string {
return fromStrokeJoinStyle[t]
}
//MarshalXMLAttr marshal StrokeJoinStyle
func (t StrokeJoinStyle) MarshalXMLAttr(name xml.Name) (xml.Attr, error) {
attr := xml.Attr{Name: name}
if v, ok := fromStrokeJoinStyle[t]; ok {
attr.Value = v
} else {
attr = xml.Attr{}
}
return attr, nil
}
//UnmarshalXMLAttr unmarshal StrokeJoinStyle
func (t *StrokeJoinStyle) UnmarshalXMLAttr(attr xml.Attr) error {
if v, ok := toStrokeJoinStyle[attr.Value]; ok {
*t = v
}
return nil
}