From: Vinícius d. S. O. <vin...@gm...> - 2013-08-15 03:16:40
|
Em Qui, 2013-08-15 às 02:48 +0200, Krzysztof Kosiński escreveu: > 2013/8/13 Vinícius dos Santos Oliveira <vin...@gm...> > > Anyway, what I need is to do the other way back (generate a SVG file > from some Geom::PathVector). The only code I found related to this > functionality lies in the toys (not part of the lib) and uses a > complicated scheme involving cairo and a lot of virtual func calls. Is > there another way? If there is not, I want to implement it and I want > to implement it fast. Would be possible to release another lib2geom > version fast if code goes okay? > > This functionality is already present in Inkscape, see > src/svg/path-string.cpp. However, it would be a good idea to move it > into 2Geom. Here is the optimal plan: Should Inkscape::SVG::PathString become a wrapper around the Geom::PathSink... like SPCurve is a wrapper around Geom::PathVector? > 1. Make a method on SVGPathSink to output a PathVector into it. You > can copy the relevant code with some modification from Inkscape, see > src/svg/svg-path.cpp, or generalize the output_svg_path function. I'm not sure if I understood what you mean. What I understood: class SVGPathSink { public: // ... // This function will read \p svgpath and make some calls to the virtual methods // moveTo, hlineTo, vlineTo... void read(const Geom::PathVector &svgpath); } > 2. Derive from SVGPathSink and implement SVGPathDataBuilder, a class > based on the code in src/svg/path-string.cpp. I'll start from this. The name DataBuilder is a bit generic. What do you think about SVGPathTextBuilder? The name clearly exposes the intent. -- Vinícius dos Santos Oliveira https://about.me/vinipsmaker |