MCPcopy Index your code
hub / github.com/gonum/plot / TestPolygon_clip

Function TestPolygon_clip

plotter/polygon_test.go:29–46  ·  view source on GitHub ↗

This test ensures that the plotter doesn't panic if there are polygons wholly outside of the plotting range.

(t *testing.T)

Source from the content-addressed store, hash-verified

27// This test ensures that the plotter doesn't panic if there are
28// polygons wholly outside of the plotting range.
29func TestPolygon_clip(t *testing.T) {
30 poly, err := plotter.NewPolygon(
31 plotter.XYs{{0, 0}, {1, 0}, {1, 1}, {0, 1}, {0, 0}},
32 )
33 if err != nil {
34 t.Fatal(err)
35 }
36 poly.Color = color.Black // Give the polygon a color to fill.
37 p := plot.New()
38 // Set the plotting range so that the polygon is outside of it.
39 p.X.Min = 2
40 p.X.Max = 5
41
42 p.Add(poly)
43 c := new(recorder.Canvas)
44 dc := draw.NewCanvas(c, vg.Centimeter, vg.Centimeter)
45 p.Draw(dc) // If this does not panic, then the test passes.
46}

Callers

nothing calls this directly

Calls 5

NewPolygonFunction · 0.92
NewFunction · 0.92
NewCanvasFunction · 0.92
DrawMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected