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); }
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); } } }
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)); }
public float?getFloatAttribute(string pAttributeName, bool pAllowParentSVGAttributes) { return(SVGParserUtils.extractFloatAttribute(this.getStringAttribute(pAttributeName, pAllowParentSVGAttributes))); }
public float?getFloatProperty(string pPropertyName) { return(SVGParserUtils.extractFloatAttribute(this.getStringProperty(pPropertyName))); }
public SVGFilter(string pID, Attributes pAttributes) { this.mID = pID; this.mHref = SVGParserUtils.parseHref(pAttributes); this.mSVGAttributes = new SVGAttributes(pAttributes, true); }