MCPcopy Create free account
hub / github.com/gonum/plot / TestMultiCanvas

Function TestMultiCanvas

vg/tee_test.go:21–55  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

19)
20
21func TestMultiCanvas(t *testing.T) {
22 p := plot.New()
23 p.Title.Text = "Title"
24 p.X.Label.Text = "x"
25 p.Y.Label.Text = "y"
26 p.X.Min = -2 * math.Pi
27 p.X.Max = +2 * math.Pi
28
29 sin := plotter.NewFunction(math.Sin)
30 sin.LineStyle.Color = color.RGBA{R: 255, A: 255}
31 sin.LineStyle.Dashes = plotutil.Dashes(1)
32
33 cos := plotter.NewFunction(math.Cos)
34 cos.LineStyle.Color = color.RGBA{B: 255, A: 255}
35 cos.LineStyle.Dashes = plotutil.Dashes(2)
36
37 p.Add(sin, cos, plotter.NewGrid())
38
39 c1 := new(recorder.Canvas)
40 c2 := new(recorder.Canvas)
41
42 const (
43 width = 10 * vg.Centimeter
44 height = 10 * vg.Centimeter
45 )
46
47 p.Draw(draw.NewCanvas(
48 vg.MultiCanvas(c1, c2, vg.MultiCanvas()),
49 width, height,
50 ))
51
52 if !reflect.DeepEqual(c1, c2) {
53 t.Fatalf("tee canvas failed to replicate drawing calls")
54 }
55}

Callers

nothing calls this directly

Calls 8

NewFunction · 0.92
NewFunctionFunction · 0.92
DashesFunction · 0.92
NewGridFunction · 0.92
NewCanvasFunction · 0.92
MultiCanvasFunction · 0.92
DrawMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected