dojox.gfx.Shape._setFillObject
dojo.require("dojox.gfx.svg");
defined in dojox/gfx/svg.js
Usage
function (f, nodeType) (view source)
var svgns = dojox.gfx.svg.xmlns.svg; this.fillStyle = f; var surface = this._getParentSurface(), defs = surface.defNode, fill = this.rawNode.getAttribute("fill"), ref = dojox.gfx.svg.getRef(fill); if(ref){ fill = ref; if(fill.tagName.toLowerCase() != nodeType.toLowerCase()){ var id = fill.id; fill.parentNode.removeChild(fill); fill = document.createElementNS(svgns, nodeType); fill.setAttribute("id", id); defs.appendChild(fill); }else{ while(fill.childNodes.length){ fill.removeChild(fill.lastChild); } } }else{ fill = document.createElementNS(svgns, nodeType); fill.setAttribute("id", dojox.gfx._base._getUniqueId()); defs.appendChild(fill); } if(nodeType == "pattern"){ if(dojo.isSafari){ fill.setAttributeNS(null, "patternUnits", "userSpaceOnUse"); }else{ fill.setAttribute("patternUnits", "userSpaceOnUse"); } var img = document.createElementNS(svgns, "image"); img.setAttribute("x", 0); img.setAttribute("y", 0); img.setAttribute("width", f.width .toFixed(8)); img.setAttribute("height", f.height.toFixed(8)); img.setAttributeNS(dojox.gfx.svg.xmlns.xlink, "href", f.src); fill.appendChild(img); }else{ if(dojo.isSafari){ fill.setAttributeNS(null, "gradientUnits", "userSpaceOnUse"); }else{ fill.setAttribute("gradientUnits", "userSpaceOnUse"); } for(var i = 0; i < f.colors.length; ++i){ var c = f.colors[i], t = document.createElementNS(svgns, "stop"), cc = c.color = dojox.gfx.normalizeColor(c.color); t.setAttribute("offset", c.offset.toFixed(8)); t.setAttribute("stop-color", cc.toCss()); t.setAttribute("stop-opacity", cc.a); fill.appendChild(t); } } this.rawNode.setAttribute("fill", "url(#" + fill.getAttribute("id") +")"); this.rawNode.removeAttribute("fill-opacity"); this.rawNode.setAttribute("fill-rule", "evenodd"); return fill;
parameter | type | description |
---|---|---|
f | ||
nodeType |