...
1
2
3
4
5 package vg
6
7 import (
8 "image"
9 "image/color"
10
11 "gonum.org/v1/plot/font"
12 )
13
14
15
16
17
18 func MultiCanvas(cs ...Canvas) Canvas {
19 return teeCanvas{cs}
20 }
21
22 type teeCanvas struct {
23 cs []Canvas
24 }
25
26
27
28
29 func (tee teeCanvas) SetLineWidth(w Length) {
30 for _, c := range tee.cs {
31 c.SetLineWidth(w)
32 }
33 }
34
35
36
37
38
39
40 func (tee teeCanvas) SetLineDash(pattern []Length, offset Length) {
41 for _, c := range tee.cs {
42 c.SetLineDash(pattern, offset)
43 }
44 }
45
46
47
48
49
50
51 func (tee teeCanvas) SetColor(c color.Color) {
52 for _, canvas := range tee.cs {
53 canvas.SetColor(c)
54 }
55 }
56
57
58
59 func (tee teeCanvas) Rotate(rad float64) {
60 for _, c := range tee.cs {
61 c.Rotate(rad)
62 }
63 }
64
65
66 func (tee teeCanvas) Translate(pt Point) {
67 for _, c := range tee.cs {
68 c.Translate(pt)
69 }
70 }
71
72
73 func (tee teeCanvas) Scale(x, y float64) {
74 for _, c := range tee.cs {
75 c.Scale(x, y)
76 }
77 }
78
79
80
81
82
83
84 func (tee teeCanvas) Push() {
85 for _, c := range tee.cs {
86 c.Push()
87 }
88 }
89
90
91
92 func (tee teeCanvas) Pop() {
93 for _, c := range tee.cs {
94 c.Pop()
95 }
96 }
97
98
99 func (tee teeCanvas) Stroke(p Path) {
100 for _, c := range tee.cs {
101 c.Stroke(p)
102 }
103 }
104
105
106 func (tee teeCanvas) Fill(p Path) {
107 for _, c := range tee.cs {
108 c.Fill(p)
109 }
110 }
111
112
113
114
115 func (tee teeCanvas) FillString(f font.Face, pt Point, text string) {
116 for _, c := range tee.cs {
117 c.FillString(f, pt, text)
118 }
119 }
120
121
122
123 func (tee teeCanvas) DrawImage(rect Rectangle, img image.Image) {
124 for _, c := range tee.cs {
125 c.DrawImage(rect, img)
126 }
127 }
128
129 var _ Canvas = (*teeCanvas)(nil)
130
View as plain text