forked from unidoc/unioffice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lineproperties.go
74 lines (63 loc) · 1.82 KB
/
lineproperties.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
// Copyright 2017 Baliance. All rights reserved.
//
// Use of this source code is governed by the terms of the Affero GNU General
// Public License version 3.0 as published by the Free Software Foundation and
// appearing in the file LICENSE included in the packaging of this file. A
// commercial license can be purchased by contacting sales@baliance.com.
package drawing
import (
"github.com/mec07/unioffice"
"github.com/mec07/unioffice/color"
"github.com/mec07/unioffice/measurement"
"github.com/mec07/unioffice/schema/soo/dml"
)
type LineProperties struct {
x *dml.CT_LineProperties
}
// X returns the inner wrapped XML type.
func (l LineProperties) X() *dml.CT_LineProperties {
return l.x
}
// SetWidth sets the line width, MS products treat zero as the minimum width
// that can be displayed.
func (l LineProperties) SetWidth(w measurement.Distance) {
l.x.WAttr = unioffice.Int32(int32(w / measurement.EMU))
}
func (l LineProperties) clearFill() {
l.x.NoFill = nil
l.x.GradFill = nil
l.x.SolidFill = nil
l.x.PattFill = nil
}
func (l LineProperties) SetNoFill() {
l.clearFill()
l.x.NoFill = dml.NewCT_NoFillProperties()
}
func (l LineProperties) SetSolidFill(c color.Color) {
l.clearFill()
l.x.SolidFill = dml.NewCT_SolidColorFillProperties()
l.x.SolidFill.SrgbClr = dml.NewCT_SRgbColor()
l.x.SolidFill.SrgbClr.ValAttr = *c.AsRGBString()
}
// LineJoin is the type of line join
type LineJoin byte
// LineJoin types
const (
LineJoinRound LineJoin = iota
LineJoinBevel
LineJoinMiter
)
// SetJoin sets the line join style.
func (l LineProperties) SetJoin(e LineJoin) {
l.x.Round = nil
l.x.Miter = nil
l.x.Bevel = nil
switch e {
case LineJoinRound:
l.x.Round = dml.NewCT_LineJoinRound()
case LineJoinBevel:
l.x.Bevel = dml.NewCT_LineJoinBevel()
case LineJoinMiter:
l.x.Miter = dml.NewCT_LineJoinMiterProperties()
}
}