MCPcopy
hub / github.com/tdewolff/canvas / TestShapes

Function TestShapes

shapes_test.go:9–31  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestShapes(t *testing.T) {
10 defer setEpsilon(1e-6)()
11
12 test.T(t, Rectangle(0.0, 10.0), &Path{})
13 test.T(t, Rectangle(5.0, 10.0), MustParseSVGPath("H5V10H0z"))
14 test.T(t, RoundedRectangle(0.0, 10.0, 0.0), &Path{})
15 test.T(t, RoundedRectangle(5.0, 10.0, 0.0), MustParseSVGPath("H5V10H0z"))
16 test.T(t, RoundedRectangle(5.0, 10.0, 2.0), MustParseSVGPath("M0 2A2 2 0 0 1 2 0L3 0A2 2 0 0 1 5 2L5 8A2 2 0 0 1 3 10L2 10A2 2 0 0 1 0 8z"))
17 test.T(t, RoundedRectangle(5.0, 10.0, -2.0), MustParseSVGPath("M0 2A2 2 0 0 0 2 0L3 0A2 2 0 0 0 5 2L5 8A2 2 0 0 0 3 10L2 10A2 2 0 0 0 0 8z"))
18 test.T(t, BeveledRectangle(0.0, 10.0, 0.0), &Path{})
19 test.T(t, BeveledRectangle(5.0, 10.0, 0.0), MustParseSVGPath("H5V10H0z"))
20 test.T(t, BeveledRectangle(5.0, 10.0, 2.0), MustParseSVGPath("M0 2L2 0L3 0L5 2L5 8L3 10L2 10L0 8z"))
21 test.T(t, Circle(0.0), &Path{})
22 test.T(t, Circle(2.0), MustParseSVGPath("M2 0A2 2 0 0 1 -2 0A2 2 0 0 1 2 0z"))
23 test.T(t, RegularPolygon(2, 2.0, true), &Path{})
24 test.T(t, RegularPolygon(4, 0.0, true), &Path{})
25 test.T(t, RegularPolygon(4, 2.0, true), MustParseSVGPath("M0 2L-2 0L0 -2L2 0z"))
26 test.T(t, RegularPolygon(3, 2.0, true), MustParseSVGPath("M0 2L-1.732051 -1L1.732051 -1z"))
27 test.T(t, RegularPolygon(3, 2.0, false), MustParseSVGPath("M-1.732051 1L0 -2L1.732051 1z"))
28 test.T(t, StarPolygon(2, 4.0, 2.0, true), &Path{})
29 test.T(t, StarPolygon(4, 4.0, 2.0, true), MustParseSVGPath("M0 4L-1.414214 1.414214L-4 0L-1.414214 -1.414214L0 -4L1.414214 -1.414214L4 0L1.414214 1.414214z"))
30 test.T(t, StarPolygon(3, 4.0, 2.0, false), MustParseSVGPath("M-3.464102 2L0 -4L3.464102 2z"))
31}

Callers

nothing calls this directly

Calls 9

setEpsilonFunction · 0.85
RectangleFunction · 0.85
MustParseSVGPathFunction · 0.85
RoundedRectangleFunction · 0.85
BeveledRectangleFunction · 0.85
CircleFunction · 0.85
RegularPolygonFunction · 0.85
StarPolygonFunction · 0.85
TMethod · 0.80

Tested by

no test coverage detected