コード例 #1
0
ファイル: SVGPaintable.cs プロジェクト: suntabu/svgimporter
        void InitDefaults()
        {
            isStrokeWidth = false;

            this._visibility      = SVGVisibility.Visible;
            this._display         = SVGDisplay.Inline;
            this._overflow        = SVGOverflow.visible;
            this._clipPathUnits   = SVGClipPathUnits.UserSpaceOnUse;
            this._clipRule        = SVGClipRule.nonzero;
            this._opacity         = 1f;
            this._fillOpacity     = 1f;
            this._strokeOpacity   = 1f;
            this._fillColor       = new SVGColor();
            this._strokeColor     = new SVGColor();
            this._strokeWidth     = new SVGLength(1);
            this._strokeLineJoin  = SVGStrokeLineJoinMethod.Miter;
            this._strokeLineCap   = SVGStrokeLineCapMethod.Butt;
            this._fillRule        = SVGFillRule.NonZero;
            this._miterLimit      = new SVGLength(4);
            this._dashArray       = null;
            this._dashOfset       = new SVGLength(0);
            this._cssStyle        = new Dictionary <string, Dictionary <string, string> >();
            this._clipPathList    = new List <List <Vector2> >();
            this._linearGradList  = new Dictionary <string, SVGLinearGradientElement>();
            this._radialGradList  = new Dictionary <string, SVGRadialGradientElement>();
            this._conicalGradList = new Dictionary <string, SVGConicalGradientElement>();
        }
コード例 #2
0
ファイル: SVGPaintable.cs プロジェクト: suntabu/svgimporter
        private void ReadClipPath(string clipPathValue)
        {
            if (clipPathValue.IndexOf("url") >= 0)
            {
                string clipPathURL = SVGStringExtractor.ExtractUrl(clipPathValue);
                if (!string.IsNullOrEmpty(clipPathURL) && SVGParser._defs.ContainsKey(clipPathURL))
                {
                    Node clipPathNode = SVGParser._defs[clipPathURL];
                    if (clipPathNode != null)
                    {
                        SVGMatrix svgMatrix = SVGMatrix.identity;

                        string clipPathUnitsString = clipPathNode.attributes.GetValue("clipPathUnits");
                        switch (clipPathUnitsString.ToLower())
                        {
                        case "userSpaceOnUse":
                            _clipPathUnits = SVGClipPathUnits.UserSpaceOnUse;
                            break;

                        case "objectBoundingBox":
                            _clipPathUnits = SVGClipPathUnits.ObjectBoundingBox;
                            break;
                        }

                        List <Node>            clipPathNodes       = clipPathNode.GetNodes();
                        List <List <Vector2> > currentClipPathList = new List <List <Vector2> >();
                        if (clipPathNodes != null && clipPathNodes.Count > 0)
                        {
                            for (int i = 0; i < clipPathNodes.Count; i++)
                            {
                                List <List <Vector2> > clipPath = GetClipPath(clipPathNodes[i], svgMatrix);
                                if (clipPath != null)
                                {
                                    currentClipPathList.AddRange(clipPath);
                                }
                            }
                        }

                        if (currentClipPathList.Count > 0)
                        {
                            currentClipPathList = SVGGeom.MergePolygon(currentClipPathList);
                        }

                        if (_clipPathList != null && _clipPathList.Count > 0)
                        {
                            _clipPathList = SVGGeom.ClipPolygon(_clipPathList, currentClipPathList);
                        }
                        else
                        {
                            _clipPathList = currentClipPathList;
                        }
                    }
                }
            }
        }
コード例 #3
0
        private void ReadClipPath(string clipPathValue)
        {
            if (clipPathValue.IndexOf("url") >= 0)
            {
                string clipPathURL = SVGStringExtractor.ExtractUrl(clipPathValue);
                if(!string.IsNullOrEmpty(clipPathURL) && SVGParser._defs.ContainsKey(clipPathURL))
                {
                    Node clipPathNode = SVGParser._defs[clipPathURL];
                    if(clipPathNode != null)
                    {
                        SVGMatrix svgMatrix = new SVGMatrix();

                        string clipPathUnitsString = clipPathNode.attributes.GetValue("clipPathUnits");
                        switch(clipPathUnitsString.ToLower())
                        {
                            case "userSpaceOnUse":
                                _clipPathUnits = SVGClipPathUnits.UserSpaceOnUse;
                                break;
                            case "objectBoundingBox":
                                _clipPathUnits = SVGClipPathUnits.ObjectBoundingBox;
                                break;
                        }

                        List<Node> clipPathNodes = clipPathNode.GetNodes();
                        List<List<Vector2>> currentClipPathList = new List<List<Vector2>>();
                        if(clipPathNodes != null && clipPathNodes.Count > 0)
                        {
                            for(int i = 0; i < clipPathNodes.Count; i++)
                            {
                                List<List<Vector2>> clipPath = GetClipPath(clipPathNodes[i], svgMatrix);
                                if(clipPath != null)
                                {
                                    currentClipPathList.AddRange(clipPath);
                                }
                            }
                        }

                        if(currentClipPathList.Count > 0)
                        {
                            currentClipPathList = SVGGeom.MergePolygon(currentClipPathList);
                        }

                        if(_clipPathList.Count > 0)
                        {
                            _clipPathList = SVGGeom.ClipPolygon(_clipPathList, currentClipPathList);
                        } else {
                            _clipPathList = currentClipPathList;
                        }
                    }
                }
            }
        }
コード例 #4
0
        void InitDefaults()
        {
            isStrokeWidth = false;

            this._visibility = SVGVisibility.Visible;
            this._display = SVGDisplay.Inline;
            this._overflow = SVGOverflow.visible;
            this._clipPathUnits = SVGClipPathUnits.UserSpaceOnUse;
            this._clipRule = SVGClipRule.nonzero;
            this._opacity = 1f;
            this._fillOpacity = 1f;
            this._strokeOpacity = 1f;
            this._fillColor = new SVGColor();
            this._strokeColor = new SVGColor();
            this._strokeWidth = new SVGLength(1);
            this._strokeLineJoin = SVGStrokeLineJoinMethod.Miter;
            this._strokeLineCap = SVGStrokeLineCapMethod.Butt;
            this._fillRule = SVGFillRule.NonZero;
            this._miterLimit = new SVGLength(4);
            this._dashArray = null;
            this._dashOfset = new SVGLength(0);
            this._cssStyle = new Dictionary<string, Dictionary<string, string>>();
            this._clipPathList = new List<List<Vector2>>();
            this._linearGradList = new Dictionary<string, SVGLinearGradientElement>();
            this._radialGradList = new Dictionary<string, SVGRadialGradientElement>();
            this._conicalGradList = new Dictionary<string, SVGConicalGradientElement>();
        }