Hi Selva.
Selva:
> I have declared one SVG file with symbols and gradients like in
> \resources\svg\defs.svg. If I tried to use external gradient from my code, it
> is not applying it properly.
>
> Element rect = doc.createElementNS(svgNS, "rect");
> rect.setAttributeNS(null, "x", "30");
> rect.setAttributeNS(null, "y", "30");
> rect.setAttributeNS(null, "id", "r2");
> rect.setAttributeNS(null, "width", "13");
> rect.setAttributeNS(null, "height", "13");
>
> rect.setAttributeNS(null, "style", "fill:defs.svg#gradient_1");
This sholud be:
rect.setAttributeNS(null, "style", "fill: url(defs.svg#gradient_1)");
> Also how to change the element’s attributes values, which is available inside
> the symbols/group?
>
> <g id="extOther" style="stroke:crimson; stroke-width:4">
> <rect x="-50" y="-50" width="100" height="100" style="fill:gold;
> stroke:none"/>
> </g>
>
> Here how to change the rectangle element's style attributes using group id?
You can use the DOM Core[1] methods to navigate to the rect from the g.
So, if you want to set the style attribute of the first element child
of the g:
var g = document.getElementById("extOther");
var rect = g.firstChild;
while (rect.nodeType != Node.ELEMENT_NODE) {
rect = rect.nextSibling;
}
rect.setAttributeNS(null, "style", whatever);
Cameron
[1] http://www.w3.org/TR/DOM-Level-2-Core/core.html
--
Cameron McCormack ICQ: 26955922
cam (at) mcc.id.au MSN: cam (at) mcc.id.au
http://mcc.id.au/ JBR: heycam (at) jabber.org
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]