-
Notifications
You must be signed in to change notification settings - Fork 0
/
line.go
68 lines (54 loc) · 1.51 KB
/
line.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
package davepdf
import (
"fmt"
)
// Line width
func (pdf *Pdf) SetLineWidth(w float64) {
pdf.lineWidth = w
pdf.page.instructions.add(fmt.Sprintf("%f w", pdf.lineWidth), "set line width")
}
// Line cap style
// With type assertions in Go 1.9, you can simply add = where you define the type.
// This tells the compiler that LineCapStyle is an alternate name for uint.
type LineCapStyle = uint
const (
LineCapStyleButt LineCapStyle = iota
LineCapStyleRound
LineCapStyleProjectingSquare
)
type LineCap struct {
style LineCapStyle
}
func (pdf *Pdf) SetLineCapStyle(s uint) {
pdf.lineCapStyle = &LineCap{style: s}
pdf.page.instructions.add(fmt.Sprintf("%d J", pdf.lineCapStyle.style), "set line cap style")
}
// Line join style
type LineJoinStyle = uint
const (
LineJoinStyleMiter LineJoinStyle = iota
LineJoinStyleRound
LineJoinStyleBevel
)
type LineJoin struct {
style LineJoinStyle
}
func (pdf *Pdf) SetLineJoinStyle(s uint) {
pdf.lineJoinStyle = &LineJoin{style: s}
pdf.page.instructions.add(fmt.Sprintf("%d j", pdf.lineJoinStyle.style), "set line join style")
}
// Line dash pattern
type LineDashPattern = uint
const (
LineDashPatternMiter LineDashPattern = iota
LineDashPatternRound
LineDashPatternBevel
)
type LineDash struct {
array []uint
phase uint
}
func (pdf *Pdf) SetLineDashPattern(array []uint, phase uint) {
pdf.lineDashPattern = &LineDash{array: array, phase: phase}
pdf.page.instructions.add(fmt.Sprintf("%d %d d", pdf.lineDashPattern.array, pdf.lineDashPattern.phase), "set line dash pattern")
}