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

Function test1

CPP/Examples/VariableOffset/VariableOffset.cpp:19–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17}
18
19void test1() {
20
21 int64_t const scale = 10;
22 double delta = 10 * scale;
23
24 ClipperOffset co;
25 co.SetDeltaCallback([delta](const Path64& path,
26 const PathD& path_norms, size_t curr_idx, size_t prev_idx)
27 {
28 // gradually scale down the offset to a minimum of 25% of delta
29 double high = static_cast<double>(path.size() - 1) * 1.25;
30 return (high - curr_idx) / high * delta;
31 });
32
33 Paths64 subject{ Ellipse(Rect64(0, 0, 200 * scale, 180 * scale)) };
34 subject[0].resize(subject[0].size() * 0.9);
35
36 co.AddPaths(subject, JoinType::Miter, EndType::Round);
37 Paths64 solution;
38 co.Execute(1.0, solution);
39
40 std::string filename = "test1.svg";
41 SvgWriter svg;
42 SvgAddOpenSubject(svg, subject, FillRule::NonZero);
43 SvgAddSolution(svg, solution, FillRule::NonZero, false);
44 SvgSaveToFile(svg, filename, 400, 400);
45 System(filename);
46}
47
48void test2() {
49

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