コード例 #1
0
        /// <summary>
        /// Clips the specified holes.
        /// </summary>
        /// <param name="shape">The shape.</param>
        /// <param name="holes">The holes.</param>
        /// <returns>Returns a new shape with the holes clipped out of the shape.</returns>
        /// <exception cref="ClipperException">Open paths have been disabled.</exception>
        public static IPath Clip(this IPath shape, IEnumerable <IPath> holes)
        {
            var clipper = new Clipper();

            clipper.AddPath(shape, ClippingType.Subject);
            clipper.AddPaths(holes, ClippingType.Clip);

            IPath[] result = clipper.GenerateClippedShapes();

            return(new ComplexPolygon(result));
        }
コード例 #2
0
        private IEnumerable <IPath> Clip(IPath shape, params IPath[] hole)
        {
            Clipper clipper = new Clipper();

            clipper.AddPath(shape, ClippingType.Subject);
            if (hole != null)
            {
                foreach (IPath s in hole)
                {
                    clipper.AddPath(s, ClippingType.Clip);
                }
            }

            return(clipper.GenerateClippedShapes());
        }
コード例 #3
0
ファイル: ClipperTests.cs プロジェクト: dlemstra/Shapes
        private ImmutableArray <IShape> Clip(IShape shape, params IShape[] hole)
        {
            var clipper = new Clipper();

            clipper.AddShape(shape, ClippingType.Subject);
            if (hole != null)
            {
                foreach (var s in hole)
                {
                    clipper.AddShape(s, ClippingType.Clip);
                }
            }

            return(clipper.GenerateClippedShapes());
        }