VgVisualElement CreateRadialGradient(VgVisualElement parentNode, SvgElement elem, SvgRadialGradientSpec spec) { //<radialGradient id="a" cx="59.6" cy="54.845" r="55.464" fx="27.165" fy="53.715" gradientUnits="userSpaceOnUse"> // <stop stop-color="#FFEB3B" offset="0" /> // <stop stop-color="#FBC02D" offset="1" /> //</radialGradient> //create linear gradient texure (or brush) VgVisualElement radialGrd = new VgVisualElement(WellknownSvgElementName.RadialGradient, spec, _vgVisualDoc); //read attribute RegisterElementById(elem, radialGrd); int childCount = elem.ChildCount; for (int i = 0; i < childCount; ++i) { SvgElement child = elem.GetChild(i); if (child.WellknowElemName == WellknownSvgElementName.Stop) { //color stop //TODO: implement this.... SvgColorStopSpec stopSpec = child.ElemSpec as SvgColorStopSpec; if (stopSpec != null) { if (spec.StopList == null) { //TODO spec.StopList = new List <SvgColorStopSpec>(); } spec.StopList.Add(stopSpec); } } else { } } return(radialGrd); }
VgVisualElement CreateLinearGradient(VgVisualElement parentNode, SvgElement elem, SvgLinearGradientSpec spec) { //https://developer.mozilla.org/en-US/docs/Web/SVG/Element/linearGradient //Categories Gradient element //Permitted content Any number of the following elements, in any order: //Descriptive elements //<animate>, <animateTransform>, <set>, <stop> //Attributes //Section //Global attributes //Section // Core attributes // Presentation attributes // Xlink attributes // class // style // externalResourcesRequired //Specific attributes //Section // gradientUnits // gradientTransform // x1 // y1 // x2 // y2 // spreadMethod // xlink:href VgVisualElement linearGrd = new VgVisualElement(WellknownSvgElementName.LinearGradient, spec, _vgVisualDoc); //read attribute RegisterElementById(elem, linearGrd); int childCount = elem.ChildCount; for (int i = 0; i < childCount; ++i) { SvgElement child = elem.GetChild(i); if (child.ElemName == "stop") { //color stop //TODO: implement this.... SvgColorStopSpec stopSpec = child.ElemSpec as SvgColorStopSpec; if (stopSpec != null) { if (spec.StopList == null) { //TODO spec.StopList = new List <SvgColorStopSpec>(); } spec.StopList.Add(stopSpec); } } else { } } return(linearGrd); }