I've noticed a number of places in the codebase where people have been painstakingly building SVG path strings by hand. There had to be a better way.
And now there is: Inkscape::SVG::PathString. It accumulates SVG path operations and is convertable to a Glib::ustring.
Inkscape::SVG::PathString str;
str.moveTo(0, 0).lineTo(100, 0) .lineTo(100, 100).lineTo(0, 100) .closePath();
return str.c_str();
(You don't have to do all the operations in one go, but you can if you want.)
Check out the before and after of using it in sp-ellipse.cpp:
http://svn.sourceforge.net/viewvc/inkscape/inkscape/trunk/src/sp-ellipse.cpp...
So, the next time you're tempted to break out a raw SVGOStringStream (or worse, sprintf) to build a path string, consider SVG::PathString instead.
-mental
On Tue, Jan 23, 2007 at 11:01:39PM -0500, MenTaLguY wrote:
I've noticed a number of places in the codebase where people have been painstakingly building SVG path strings by hand. There had to be a better way.
And now there is: Inkscape::SVG::PathString. It accumulates SVG path operations and is convertable to a Glib::ustring.
Inkscape::SVG::PathString str;
str.moveTo(0, 0).lineTo(100, 0) .lineTo(100, 100).lineTo(0, 100) .closePath();
return str.c_str();
(You don't have to do all the operations in one go, but you can if you want.)
Check out the before and after of using it in sp-ellipse.cpp:
http://svn.sourceforge.net/viewvc/inkscape/inkscape/trunk/src/sp-ellipse.cpp...
So, the next time you're tempted to break out a raw SVGOStringStream (or worse, sprintf) to build a path string, consider SVG::PathString instead.
-mental
Does this class also do parsing of path strings?
Bryce
On Wed, 2007-01-24 at 10:31 -0800, Bryce Harrington wrote:
Does this class also do parsing of path strings?
Nope. I think that's a job for a separate class -- basically something like a SAX parser, that just generates events rather than generating a specific internal representation.
-mental
participants (2)
-
Bryce Harrington
-
MenTaLguY