How can I add an element to the SVG DOM

后端 未结 1 1503
执笔经年
执笔经年 2020-12-30 04:07

I have a web page with a jpg image that the user draw an SVG doodle on top of using Raphael.

I want to allow the user to save a merged rasterised version of this whe

1条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-30 04:49

    Here is one way of doing it:

    var svgimg = document.createElementNS('http://www.w3.org/2000/svg','image');
    svgimg.setAttributeNS(null,'height','200');
    svgimg.setAttributeNS(null,'width','200');
    svgimg.setAttributeNS('http://www.w3.org/1999/xlink','href', 'myimage.jpg');
    svgimg.setAttributeNS(null,'x','10');
    svgimg.setAttributeNS(null,'y','10');
    svgimg.setAttributeNS(null, 'visibility', 'visible');
    $('svg').append(svgimg);
    

    0 讨论(0)
提交回复
热议问题