예제 #1
0
 public static void DrawPolygonContours(this IDebugCanvas canvas, IReadOnlyList <Polygon2> polys, StrokeStyle strokeStyle)
 {
     foreach (var poly in polys)
     {
         canvas.DrawPolygonContour(poly, strokeStyle);
     }
 }
예제 #2
0
        public static void DrawPolyNode(this IDebugCanvas canvas, PolyNode polytree, StrokeStyle landStroke = null, StrokeStyle holeStroke = null)
        {
            landStroke = landStroke ?? new StrokeStyle(Color.Orange);
            holeStroke = holeStroke ?? new StrokeStyle(Color.Brown);

            canvas.BatchDraw(() => {
                var s = new Stack <PolyNode>();
                s.Push(polytree);
                while (s.Any())
                {
                    var node = s.Pop();
                    node.Childs.ForEach(s.Push);
                    if (node.Contour.Any())
                    {
                        canvas.DrawPolygonContour(
                            new Polygon2(node.Contour.Map(p => new IntVector2(p.X, p.Y)).ToList()),
                            node.IsHole ? holeStroke : landStroke);
                    }
                }
            });
        }