skip to Main Content

Html – How to make a textPath but for image not path in svg

I'm doing pretty simple svg rendering, like <svg> <image href="rounded_image.svg" width="35" height="35" /> </svg> where rounded image looks like this <svg width="652" height="652" viewBox="0 0 652 652" fill="none" xmlns="http://www.w3.org/2000/svg"><g filter="url(#filter0_ddiii_724_876)"><path fill-rule="evenodd" clip-rule="evenodd" d="M296 390C347.915 390 390 347.915 390 296C390 244.085…

VIEW QUESTION

Javascript – XMLSerializer.serializeToString and img data:uri has something wrong with comment node

const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg') const foreignObject = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); const div = document.createElement('div') div.innerHTML = '<!-- -- -->' foreignObject.appendChild(div) svg.appendChild(foreignObject); const img = document.createElement('img') img.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(svg))}` document.body.appendChild(img) the <!-- -- --> makes the img load error,change to…

VIEW QUESTION

Javascript – XMLSerializer.serializeToString has a bug on process script tag

const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg') const foreignObject = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'); foreignObject.appendChild(document.createElement('script')) svg.appendChild(foreignObject); new XMLSerializer().serializeToString(svg) // "<svg xmlns="http://www.w3.org/2000/svg"><foreignObject><script xmlns="http://www.w3.org/1999/xhtml"></script></foreignObject></svg>" the code string <script> becomes to x3Cscript> and </script> becomes to x3C/script> ,the result is not right how can i fix this?…

VIEW QUESTION
Back To Top
Search