コード例 #1
0
        public static List <List <Vector2> > GetClipPath(SVGMatrix matrix, SVGPathElement svgElement)
        {
            List <List <Vector2> > path = GetPaths(matrix, svgElement);

            if (path == null || path.Count == 0)
            {
                return(null);
            }

            List <List <Vector2> > clipPath = new List <List <Vector2> >();

            if (svgElement.paintable.IsFill())
            {
                clipPath.AddRange(path);
            }

            if (svgElement.paintable.IsStroke())
            {
                List <StrokeSegment[]> segments = new List <StrokeSegment[]>();
                for (int i = 0; i < path.Count; i++)
                {
                    if (path[i] == null || path[i].Count < 2)
                    {
                        continue;
                    }
                    segments.Add(SVGSimplePath.GetSegments(path[i]));
                }

                List <List <Vector2> > strokePath = SVGLineUtils.StrokeShape(segments, svgElement.paintable.strokeWidth, Color.black, SVGSimplePath.GetStrokeLineJoin(svgElement.paintable.strokeLineJoin), SVGSimplePath.GetStrokeLineCap(svgElement.paintable.strokeLineCap), svgElement.paintable.miterLimit, svgElement.paintable.dashArray, svgElement.paintable.dashOffset, ClosePathRule.AUTO, SVGGraphics.roundQuality);
                if (strokePath != null && strokePath.Count > 0)
                {
                    clipPath.AddRange(strokePath);
                }
            }

            return(clipPath);
        }
コード例 #2
0
ファイル: SVGLineElement.cs プロジェクト: suntabu/svgimporter
        public List <List <Vector2> > GetClipPath()
        {
            List <List <Vector2> > path = GetPath();

            if (path == null || path.Count == 0 || path[0] == null || path[0].Count == 0)
            {
                return(null);
            }

            List <List <Vector2> > clipPath = new List <List <Vector2> >();

            List <StrokeSegment[]> segments = new List <StrokeSegment[]>()
            {
                SVGSimplePath.GetSegments(path[0])
            };
            List <List <Vector2> > strokePath = SVGLineUtils.StrokeShape(segments, paintable.strokeWidth, Color.black, SVGSimplePath.GetStrokeLineJoin(paintable.strokeLineJoin), SVGSimplePath.GetStrokeLineCap(paintable.strokeLineCap), paintable.miterLimit, paintable.dashArray, paintable.dashOffset, ClosePathRule.NEVER, SVGGraphics.roundQuality);

            if (strokePath != null && strokePath.Count > 0)
            {
                clipPath.AddRange(strokePath);
            }

            return(clipPath);
        }