...
1
2
3
4
5 package vgimg_test
6
7 import (
8 "image"
9 "image/color"
10
11 "gonum.org/v1/plot"
12 "gonum.org/v1/plot/vg"
13 "gonum.org/v1/plot/vg/draw"
14 "gonum.org/v1/plot/vg/vgimg"
15 )
16
17 func ExampleUseDPI() {
18 p := plot.New()
19 p.Title.Text = "Title"
20 p.X.Label.Text = "X"
21 p.Y.Label.Text = "Y"
22
23 const (
24 width = 10 * vg.Centimeter
25 height = 10 * vg.Centimeter
26 )
27
28
29
30
31 c := vgimg.NewWith(
32 vgimg.UseWH(width, height),
33 vgimg.UseDPI(72),
34 )
35
36 dc := draw.New(c)
37 p.Draw(dc)
38 }
39
40 func ExampleUseImage() {
41 p := plot.New()
42 p.Title.Text = "Title"
43 p.X.Label.Text = "X"
44 p.Y.Label.Text = "Y"
45
46 img := image.NewRGBA(image.Rect(0, 100, 0, 100))
47
48
49
50
51
52 c := vgimg.NewWith(
53 vgimg.UseImage(img),
54 )
55
56 dc := draw.New(c)
57 p.Draw(dc)
58 }
59
60 func ExampleUseBackgroundColor() {
61 p := plot.New()
62 p.Title.Text = "Title"
63 p.X.Label.Text = "X"
64 p.Y.Label.Text = "Y"
65
66 const (
67 width = 10 * vg.Centimeter
68 height = 10 * vg.Centimeter
69 )
70
71
72
73 c := vgimg.NewWith(
74 vgimg.UseWH(width, height),
75 vgimg.UseBackgroundColor(color.Transparent),
76 )
77
78 dc := draw.New(c)
79 p.Draw(dc)
80 }
81
View as plain text