1
我很想知道是否可以在JavaScript文件中使用JavaScript/jQuery選擇SVG文件,例如example.svg,並將多邊形/多邊形/路徑作爲字符串進行進一步操作而不保存圖像到桌面並使用InkScape/Adobe Illustrator或任何其他矢量處理程序手動提取代碼。如何使用JavaScript將SVG圖像轉換爲SVG代碼以獲取多邊形或路徑?
這裏就是我的目標:
前
<img src="example.svg" />
後
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<polygon points="100,10 40,180 190,....." style="......"/>
</svg>
,我希望與之合作的代碼:
$(document).ready(function() {
// convert the svg into polygon, for instance
function convertSVG(svg){
...
}
convertSVG(/* get that SVG in img tags */);
})
如果您已經將它作爲圖像加載,但不是這樣,但如果它是對象或嵌入或iframe則可能。 – 2013-03-19 16:13:23