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

Function test2

CPP/Examples/VariableOffset/VariableOffset.cpp:48–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46}
47
48void test2() {
49
50 int64_t const scale = 10;
51 double delta = 10 * scale;
52
53 ClipperOffset co;
54 co.SetDeltaCallback([delta](const Path64& path,
55 const PathD& path_norms, size_t curr_idx, size_t prev_idx) {
56 // calculate offset based on distance from the middle of the path
57 double mid_idx = static_cast<double>(path.size()) / 2.0;
58 return delta * (1.0 - 0.70 * (std::fabs(curr_idx - mid_idx) / mid_idx));
59 });
60
61 Paths64 subject{ Ellipse(Rect64(0, 0, 200 * scale, 180 * scale)) };
62 subject[0].resize(subject[0].size() * 0.9);
63
64 co.AddPaths(subject, JoinType::Miter, EndType::Round);
65 Paths64 solution;
66 co.Execute(1.0, solution);
67
68 std::string filename = "test2.svg";
69 SvgWriter svg;
70 SvgAddOpenSubject(svg, subject, FillRule::NonZero);
71 SvgAddSolution(svg, solution, FillRule::NonZero, false);
72 SvgSaveToFile(svg, filename, 400, 400);
73 System(filename);
74}
75
76void test3() {
77

Callers 1

mainFunction · 0.85

Calls 9

EllipseFunction · 0.85
Rect64Class · 0.85
SvgAddOpenSubjectFunction · 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