sample code:

var selection = document.getElementById("anyElement");
var bbox = selection.getBBox();
var cx = bbox.x + bbox.width/2;
var cy = bbox.y + bbox.height/2;
var width = 100;
var height = 100;
var x = cx-width/2;
var y = cy-width/2;
var image = document.createElementNS("http://www.w3.org/2000/svg";,
"image");
image.setAttributeNS("http://www.w3.org/1999/xlink";, "xlink:href",
"image.png");
image.setAttributeNS(null, "x", ""+x);
image.setAttributeNS(null, "y", ""+y);
image.setAttributeNS(null, "width", ""+width);
image.setAttributeNS(null, "height", ""+height);
selection.parentNode.insertBefore(image, selection.nextSibling);

--- In [email protected], Iswaria Karunakaran
<[EMAIL PROTECTED]> wrote:
>
> I have six leaves in a svg page. Each leaf is grouped under a <g>
with id.
> 
> I want to add a image inside or above one of <g> depending upon the
user selection.
> 
> Using getdocumentById, I can able to get the particular element I want.
> 
> But I know how to set the x and y position for the image.
>     
> The svg file for your reference:
>     
> http://www.ifpindia.org/tmp/typ_smtd.svg
> 
> and the output should be like this: http://www.ifpindia.org/tmp/apex.gif
> 
> 
>       
> 
> [Non-text portions of this message have been removed]
>



------------------------------------

-----
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my 
membership"
----Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/svg-developers/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/svg-developers/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

Reply via email to