public static RadialGradient ConvertRadialGradient(XElement svgGradient, List <string> warnings) { const string typeName = "radialGradient"; if (svgGradient.Name != Namespace.Svg + typeName) { throw new ArgumentException("Argument is not the expected <" + typeName + "> SVG element"); } var hrefElement = GetGradientHrefElement(svgGradient, warnings); float cx = 0, cy = 0, r = 0; if (GetAttribute("cx", svgGradient, hrefElement) is XAttribute cxAttribute) { var f = cxAttribute.Value.ToPathOffset(); if (!float.IsNaN(f)) { cx = f; } else { warnings.AddWarning("Could not parse cx parameter of <" + typeName + " id='" + svgGradient.Attribute("id")?.Value + "'>"); } } if (GetAttribute("cy", svgGradient, hrefElement) is XAttribute cyAttribute) { var f = cyAttribute.Value.ToPathOffset(); if (!float.IsNaN(f)) { cy = f; } else { warnings.AddWarning("Could not parse cy parameter of <" + typeName + " id='" + svgGradient.Attribute("id")?.Value + "'>"); } } if (svgGradient.Attribute("fx") is XAttribute fxAttribute) { var f = fxAttribute.Value.ToPathOffset(); if (!float.IsNaN(f)) { cx = f; warnings.AddWarning("Found 'fx' attribute in SVG " + typeName + ". Emulating AndroidStudio VectorAsset Generator by replacing 'rx' with 'fx'."); } } if (svgGradient.Attribute("fy") is XAttribute fyAttribute) { var f = fyAttribute.Value.ToPathOffset(); if (!float.IsNaN(f)) { cy = f; warnings.AddWarning("Found 'fy' attribute in SVG " + typeName + ". Emulating AndroidStudio VectorAsset Generator by replacing 'ry' with 'fy'."); } } if (GetAttribute("r", svgGradient, hrefElement) is XAttribute rAttribute) { var f = rAttribute.Value.ToPathOffset(); if (!float.IsNaN(f)) { r = f; } else { warnings.AddWarning("Could not parse r parameter of <" + typeName + " id='" + svgGradient.Attribute("id")?.Value + "'>"); } } if (r <= 0) { r = 0.5f; } var avGradient = new RadialGradient(); avGradient.SetAndroidAttributeValue("centerX", cx); avGradient.SetAndroidAttributeValue("centerY", cy); avGradient.SetAndroidAttributeValue("gradientRadius", r); SetCommonGradientAttributes(svgGradient, hrefElement, avGradient, warnings); return(avGradient); }