Exemplo n.º 1
0
        //==========================================================================
        public SvgStopElement(SvgDocument document, SvgBaseElement parent, XElement stopElement)
            : base(document, parent, stopElement)
        {
            XAttribute offset_attribute = stopElement.Attribute("offset");

            if (offset_attribute != null)
            {
                Offset = SvgLength.Parse(offset_attribute.Value);
            }

            XAttribute stop_color_attribute = stopElement.Attribute("stop-color");

            if (stop_color_attribute != null)
            {
                Color = SvgColorParser.Parse(stop_color_attribute.Value);
            }

            XAttribute stop_opacity_attribute = stopElement.Attribute("stop-opacity");

            if (stop_opacity_attribute != null)
            {
                Opacity = SvgLength.Parse(stop_opacity_attribute.Value);
            }
        }
Exemplo n.º 2
0
        //==========================================================================
        public static SvgPaint Parse(string value)
        {
            if (string.IsNullOrWhiteSpace(value) || string.IsNullOrEmpty(value))
            {
                throw new ArgumentException("value must not be null or empty", nameof(value));
            }

            value = value.Trim();

            if (value.StartsWith("url"))
            {
                string url = value.Substring(3).Trim();
                if (url.StartsWith("(") && url.EndsWith(")"))
                {
                    url = url.Substring(1, url.Length - 2).Trim();
                    if (url.StartsWith("#"))
                    {
                        return(new SvgUrlPaint(url.Substring(1).Trim()));
                    }
                }
            }

            return(new SvgColorPaint(SvgColorParser.Parse(value)));
        }