Closed jim-jiang-github closed 3 months ago
C# project, Use nuget Clipper2, net6.0
S1: Code:
static void Main(string[] args) { List<PointD> ps = new List<PointD>(); ps.Add(new PointD(200, 1000)); ps.Add(new PointD(3300, 1000)); ps.Add(new PointD(3300, 600)); ps.Add(new PointD(200, 600)); ps.Add(new PointD(200, 1000)); PathsD psd = new PathsD(); psd.Add(new PathD(ps)); double width = 15000; double height = 1520; int split = 500; SvgWriter svg = new(FillRule.NonZero); for (int i = 0; i < (int)(width / split); i++) { var startX = i * split; var endX = split * i + split; RectD clipRect = new RectD(Math.Max(0, startX - 2), 0, endX, height); PathsD paths = Clipper.RectClipLines(clipRect, psd, 0); SvgUtils.AddOpenSubject(svg, paths); } svg.SaveToFile("rectclip.svg"); }
result:
S2: Code:
static void Main(string[] args) { List<PointD> ps = new List<PointD>(); ps.Add(new PointD(200, 1000)); for (int i = 1; i < 32; i++) { ps.Add(new PointD(i * 100 + 200, 1000)); } ps.Add(new PointD(3300, 1000)); ps.Add(new PointD(3300, 600)); for (int i = 1; i < 32; i++) { ps.Add(new PointD(3300 - i * 100, 600)); } ps.Add(new PointD(200, 600)); ps.Add(new PointD(200, 1000)); PathsD psd = new PathsD(); psd.Add(new PathD(ps)); double width = 15000; double height = 1520; int split = 500; SvgWriter svg = new(FillRule.NonZero); for (int i = 0; i < (int)(width / split); i++) { var startX = i * split; var endX = split * i + split; RectD clipRect = new RectD(Math.Max(0, startX - 2), 0, endX, height); PathsD paths = Clipper.RectClipLines(clipRect, psd, 0); SvgUtils.AddOpenSubject(svg, paths); } svg.SaveToFile("rectclip.svg"); }
Demo: [Uploading Clipper2Lib.Test.zip…]()
C# project, Use nuget Clipper2, net6.0
S1: Code:
result:![rectclip](https://github.com/AngusJohnson/Clipper2/assets/29189410/fa6241e1-3643-436a-a9a4-bfe775ced3bf)
S2: Code:
result:![rectclip1](https://github.com/AngusJohnson/Clipper2/assets/29189410/a3bfb32d-05d9-4aaa-b344-5ea836466a6b)
Demo: [Uploading Clipper2Lib.Test.zip…]()