MCPcopy Create free account
hub / github.com/cogentcore/core / TestLine

Function TestLine

plot/plots/plot_test.go:25–81  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

23}
24
25func TestLine(t *testing.T) {
26 pt := plot.New()
27 pt.Title.Text = "Test Line"
28 pt.X.Min = 0
29 pt.X.Max = 100
30 pt.X.Label.Text = "X Axis"
31 pt.Y.Min = 0
32 pt.Y.Max = 100
33 pt.Y.Label.Text = "Y Axis"
34
35 // note: making two overlapping series
36 data := make(plot.XYs, 42)
37 for i := range data {
38 x := float32(i % 21)
39 data[i].X = x * 5
40 if i < 21 {
41 data[i].Y = float32(50) + 40*math32.Sin((x/8)*math32.Pi)
42 } else {
43 data[i].Y = float32(50) + 40*math32.Cos((x/8)*math32.Pi)
44 }
45 }
46
47 l1, err := NewLine(data)
48 if err != nil {
49 t.Error(err.Error())
50 }
51 pt.Add(l1)
52 pt.Legend.Add("Sine", l1)
53 pt.Legend.Add("Cos", l1)
54
55 pt.Resize(image.Point{640, 480})
56 pt.Draw()
57 imagex.Assert(t, pt.Pixels, "line.png")
58
59 l1.Fill = colors.Uniform(colors.Yellow)
60 pt.Draw()
61 imagex.Assert(t, pt.Pixels, "line-fill.png")
62
63 l1.StepStyle = PreStep
64 pt.Draw()
65 imagex.Assert(t, pt.Pixels, "line-prestep.png")
66
67 l1.StepStyle = MidStep
68 pt.Draw()
69 imagex.Assert(t, pt.Pixels, "line-midstep.png")
70
71 l1.StepStyle = PostStep
72 pt.Draw()
73 imagex.Assert(t, pt.Pixels, "line-poststep.png")
74
75 l1.StepStyle = NoStep
76 l1.Fill = nil
77 l1.NegativeXDraw = true
78 pt.Draw()
79 imagex.Assert(t, pt.Pixels, "line-negx.png")
80
81}
82

Callers

nothing calls this directly

Calls 10

NewFunction · 0.92
SinFunction · 0.92
CosFunction · 0.92
AssertFunction · 0.92
UniformFunction · 0.92
NewLineFunction · 0.70
ErrorMethod · 0.65
AddMethod · 0.65
DrawMethod · 0.65
ResizeMethod · 0.45

Tested by

no test coverage detected