MCPcopy Create free account
hub / github.com/AngusJohnson/Clipper2 / test3

Function test3

CPP/Examples/VariableOffset/VariableOffset.cpp:76–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76void test3() {
77
78 double radius = 5000.0;
79 Paths64 subject = { Ellipse(Rect64(-radius, -radius, radius, radius), 200) };
80
81 ClipperOffset co;
82 co.AddPaths(subject, JoinType::Miter, EndType::Polygon);
83
84 co.SetDeltaCallback([radius](const Path64& path,
85 const PathD& path_norms, size_t curr_idx, size_t prev_idx) {
86 // when multiplying the x & y of edge unit normal vectors, the value will be
87 // largest (0.5) when edges are at 45 deg. and least (-0.5) at negative 45 deg.
88 double delta = path_norms[curr_idx].y * path_norms[curr_idx].x;
89 return radius * 0.5 + radius * delta;
90 });
91
92 // solution
93 Paths64 solution;
94 co.Execute(1.0, solution);
95
96 std::string filename = "test3.svg";
97 SvgWriter svg;
98 SvgAddSubject(svg, subject, FillRule::NonZero);
99 SvgAddSolution(svg, solution, FillRule::NonZero, false);
100 SvgSaveToFile(svg, filename, 400, 400);
101 System(filename);
102}
103
104void test4() {
105

Callers 1

mainFunction · 0.85

Calls 9

EllipseFunction · 0.85
Rect64Class · 0.85
SvgAddSubjectFunction · 0.85
SvgAddSolutionFunction · 0.85
SvgSaveToFileFunction · 0.85
SetDeltaCallbackMethod · 0.80
SystemFunction · 0.70
AddPathsMethod · 0.45
ExecuteMethod · 0.45

Tested by

no test coverage detected