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

Method Main

CSharp/Examples/USINGZ/Program.cs:42–77  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

40 }
41
42 public static void Main()
43 {
44 PathsD solution = new();
45 PathsD subject = new()
46 {
47 Clipper.MakePathZ(new double[] { 100,50,1, 10,79,2, 65,2,3, 65,98,4, 10,21,5 })
48 };
49
50 subject = Clipper.ScalePaths(subject, 3);
51 ClipperD clipperD = new ();
52 MyCallbacks cb = new ();
53 clipperD.ZCallback = cb.MyCallbackD;
54 clipperD.AddSubject(subject);
55 clipperD.Execute(ClipType.Union, FillRule.NonZero, solution);
56
57 solution = Clipper.InflatePaths(solution, 12, JoinType.Miter, EndType.Polygon, 6);
58 Console.WriteLine(solution.ToString(0));
59
60 SvgWriter svg = new (FillRule.NonZero);
61 SvgUtils.AddSubject(svg, subject);
62 SvgUtils.AddSolution(svg, solution, true);
63
64 PathsD ellipses = new ();
65 for (int i = 0; i < solution[0].Count; i++)
66 {
67 if (solution[0][i].z < 0)
68 ellipses.Add(Clipper.Ellipse(
69 new PointD(solution[0][i].x, solution[0][i].y), 4));
70 if (solution[0][i].z > 0)
71 svg.AddText(solution[0][i].z.ToString(),
72 solution[0][i].x -11, solution[0][i].y + 10, 14, 0xFF000000);
73 }
74 svg.AddClosedPaths(ellipses, 0x20FF0000, 0xFFFF0000, 1);
75 svg.SaveToFile("usingz.svg", 500, 500, 50);
76 OpenFileWithDefaultApp("usingz.svg");
77 }
78
79 public static void OpenFileWithDefaultApp(string filename)
80 {

Callers

nothing calls this directly

Calls 12

MakePathZMethod · 0.80
ScalePathsMethod · 0.80
InflatePathsMethod · 0.80
EllipseMethod · 0.80
AddSubjectMethod · 0.45
ExecuteMethod · 0.45
ToStringMethod · 0.45
AddSolutionMethod · 0.45
AddMethod · 0.45
AddTextMethod · 0.45
AddClosedPathsMethod · 0.45
SaveToFileMethod · 0.45

Tested by

no test coverage detected