Store all SVG elements into an array of ofPolyline

Hi there,
I’d like to parse svgs file and to store each “element” as a path.
The purpose is to draw progressively an svg file by following some aesthetic rules I’ll define later.

anyone ?

This is pretty straightfoward with the ofxSVG addon. You can check the addon example in OF’s examples folder.
This way you´ll get a vector of ofPoints, ofPath and ofPolyline objects to archive your objetive.

  
  
   ofxSVG svg;  
   svg.load("yourfile.svg");   
   for (int i = 0;i < svg.getNumPath();i++){  
           ofPath p = svg.getPathAt(i);  
           p.setPolyWindingMode(OF_POLY_WINDING_ODD);  
           vector<ofPolyline> vpl = p.getOutline(); // Here!  
           // And if you want vertices:  
           for(int z = 0; z < vpl.size(); z++) {  
                     ofPolyline pl = vpl[z];  
                     vector<ofPoint> vp = pl.getVertices();  
           }  
    }  

Hope this helps,

P.

this is definitively straightforward, indeed.
thanks for your answer :slight_smile:

Is it possible to do the reverse and save an ofPolyline into a SVG?