我想用洞绘画。
要做到这一点,我必须将图形切割成三角形并逐一绘制。
这里我有八个外部三角形和两个内部。我想,我只会带外景并画出像
一样const int y = 100;
const int x = 100;
const int offset = 20;
IList<PolygonPoint> bounds = new List<PolygonPoint>
{
new PolygonPoint(0,0),
new PolygonPoint(0, y),
new PolygonPoint(x, y),
new PolygonPoint(x, 0),
};
IList<PolygonPoint> hole = new List<PolygonPoint>
{
new PolygonPoint(offset, offset),
new PolygonPoint(x - offset, offset),
new PolygonPoint(offset, y - offset),
new PolygonPoint(x - offset, y - offset),
};
Polygon polygon = new Polygon(bounds); // here polygon contains four dots
polygon.AddHole(new Polygon(hole)); // and here - eight
P2T.Triangulate(polygon); // here I get ten triangles
foreach (var triangle in polygon.Triangles.Where(tr => tr.IsInterior)) // <-- problem
{
// draw
}
但多边形中的每个三角形都有IsInterior == true。我做错了什么?
P.S。对于PointSet,在同一情况下,此属性始终为false。