Convert SVG polygon to path

后端 未结 4 1073
春和景丽
春和景丽 2020-12-04 13:34

I have a fairly large SVG file of administrative subdivisions that I need to work with in Raphael.JS (it has 600 polygons and weights 1.2 Mb).

Now, I need to convert

4条回答
  •  遥遥无期
    2020-12-04 14:05

    Copying everything from the developer tools seems pretty inconvenient. You could use an XSLT to transform polygons and polylines to paths:

    
    
    
      
      
        
          
        
      
    
      
      
        
          
        
      
    
      
      
        
          
          
          
            
          
        
      
    
    

    Any attributes of the polygon/polyline elements will be carried over to the path element. This is also suitable for batch processing. You can run this using any XSLT processor (Saxon, Xalan, xsltproc, Altova...) or even in-browser, using the XSLTProcessor object, like:

    var xsltProcessor = new XSLTProcessor();
    xsltProcessor.importStylesheet(stylesheet);
    var transformedSVG = xsltProcessor.transformToFragment(svgDocument).firstChild
    

    (Similar question: Examples of polygons drawn by path vs polygon in SVG)

提交回复
热议问题