コード例 #1
0
ファイル: SVGGradient.cs プロジェクト: znsoft/TUSA
 public SVGGradient(string pID, bool pLinear, Attributes pAttributes)
 {
     this.mID            = pID;
     this.mHref          = SVGParserUtils.parseHref(pAttributes);
     this.mLinear        = pLinear;
     this.mSVGAttributes = new SVGAttributes(pAttributes, true);
 }
コード例 #2
0
        bool setColorProperties(SVGProperties pSVGProperties, bool pModeFill)           // TODO throw SVGParseException
        {
            string colorProperty = pSVGProperties.getStringProperty(pModeFill ? SVGConstants.ATTRIBUTE_FILL : SVGConstants.ATTRIBUTE_STROKE);

            if (colorProperty == null)
            {
                return(false);
            }

            string filterProperty = pSVGProperties.getStringProperty(SVGConstants.ATTRIBUTE_FILTER);

            if (filterProperty != null)
            {
                if (SVGProperties.IsUrlProperty(filterProperty))
                {
                    string filterID = SVGParserUtils.extractIDFromURLProperty(filterProperty);

                    this.getFilter(filterID).applyFilterElements(this.mPaint);
                }
                else
                {
                    return(false);
                }
            }

            if (SVGProperties.IsUrlProperty(colorProperty))
            {
                string gradientID = SVGParserUtils.extractIDFromURLProperty(colorProperty);

                this.mPaint.SetShader(this.getGradientShader(gradientID));
                return(true);
            }
            else
            {
                int?color = this.parseColor(colorProperty);
                if (color != null)
                {
                    if (!isStancil)
                    {
                        this.applyColor(pSVGProperties, color.Value, pModeFill);
                    }
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
コード例 #3
0
        Color?parseColor(string pString)
        {
            /* TODO Test if explicit pattern matching is faster:
             *
             * RGB:		/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/
             * #RRGGBB:	/^(\w{2})(\w{2})(\w{2})$/
             * #RGB:	/^(\w{1})(\w{1})(\w{1})$/
             */

            Color?parsedColor;

            if (pString == null)
            {
                parsedColor = null;
            }
            else if (SVGProperties.isHexProperty(pString))
            {
                parsedColor = SVGParserUtils.extractColorFromHexProperty(pString);
            }
            else if (SVGProperties.isRgbProperty(pString))
            {
                parsedColor = SVGParserUtils.extractColorFromRGBProperty(pString);
            }
            else
            {
                Color?colorByName = ColorUtils.GetColorByName(pString.Trim());
                if (colorByName != null)
                {
                    parsedColor = colorByName;
                }
                else
                {
                    parsedColor = SVGParserUtils.extraColorIntegerProperty(pString);
                }
            }
            return(this.applySVGColorMapper(parsedColor.Value));
        }
コード例 #4
0
ファイル: SVGAttributes.cs プロジェクト: znsoft/TUSA
 public float?getFloatAttribute(string pAttributeName, bool pAllowParentSVGAttributes)
 {
     return(SVGParserUtils.extractFloatAttribute(this.getStringAttribute(pAttributeName, pAllowParentSVGAttributes)));
 }
コード例 #5
0
ファイル: SVGProperties.cs プロジェクト: znsoft/TUSA
 public float?getFloatProperty(string pPropertyName)
 {
     return(SVGParserUtils.extractFloatAttribute(this.getStringProperty(pPropertyName)));
 }
コード例 #6
0
ファイル: SVGFilter.cs プロジェクト: znsoft/TUSA
 public SVGFilter(string pID, Attributes pAttributes)
 {
     this.mID            = pID;
     this.mHref          = SVGParserUtils.parseHref(pAttributes);
     this.mSVGAttributes = new SVGAttributes(pAttributes, true);
 }