public void EqualsTest() { var solid = new KtSolidRegion(CreateArbitraryRegion()); var solid2 = new KtSolidRegion(CreateArbitraryRegion()); Assert.AreEqual(solid2, solid); }
internal void Add(KtSolidRegion region) { if (region == null) { throw new ArgumentNullException($"An Empty region= ({region}) cannot be added to the polygon= ({this})"); } var(intersected, notintersected) = _regions.Fork(reg => region.IsIntersecting(reg)); if (intersected.IsEmpty()) { _regions.Add(region); } else { _regions = notintersected.Concat(new[] { intersected.Aggregate(region, (total, reg) => total.Add(reg).FirstOrDefault()) }).ToList(); } }
public static void DrawHoledRegion(this Graphics gr, KtSolidRegion reg, Color color) { if (reg.Count < 3) { return; } using var gp = new GraphicsPath(); gp.AddPolygon(reg.ToArrayOfPoints()); foreach (var hole in reg.Holes) { gp.AddPolygon(hole.ToArrayOfPoints()); } using var pen = new Pen(color); gr.FillPath(pen.Brush, gp); using var pen2 = new Pen(Color.Red); pen2.Width = 2; gr.DrawPath(pen2, gp); }