From c0e018442303925a133777d188adc1700e82c866 Mon Sep 17 00:00:00 2001 From: johanengelen Date: Tue, 2 Sep 2008 22:14:59 +0000 Subject: [PATCH] add method to write single paths to svg --- src/svg/svg-path.cpp | 28 ++++++++++++++++++++-------- src/svg/svg.h | 1 + 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/svg/svg-path.cpp b/src/svg/svg-path.cpp index 12b282577..81eb7da59 100644 --- a/src/svg/svg-path.cpp +++ b/src/svg/svg-path.cpp @@ -784,20 +784,32 @@ static void sp_svg_write_curve(Inkscape::SVG::PathString & str, Geom::Curve cons } } +static void sp_svg_write_path(Inkscape::SVG::PathString & str, Geom::Path const & p) { + str.moveTo( p.initialPoint()[0], p.initialPoint()[1] ); + + for(Geom::Path::const_iterator cit = p.begin(); cit != p.end_open(); cit++) { + sp_svg_write_curve(str, &(*cit)); + } + + if (p.closed()) { + str.closePath(); + } +} + gchar * sp_svg_write_path(Geom::PathVector const &p) { Inkscape::SVG::PathString str; for(Geom::PathVector::const_iterator pit = p.begin(); pit != p.end(); pit++) { - str.moveTo( pit->initialPoint()[0], pit->initialPoint()[1] ); + sp_svg_write_path(str, *pit); + } - for(Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_open(); cit++) { - sp_svg_write_curve(str, &(*cit)); - } + return g_strdup(str.c_str()); +} - if (pit->closed()) { - str.closePath(); - } - } +gchar * sp_svg_write_path(Geom::Path const &p) { + Inkscape::SVG::PathString str; + + sp_svg_write_path(str, p); return g_strdup(str.c_str()); } diff --git a/src/svg/svg.h b/src/svg/svg.h index 7c9ac5a91..8617d4865 100644 --- a/src/svg/svg.h +++ b/src/svg/svg.h @@ -70,6 +70,7 @@ NArtBpath * sp_svg_read_path (const char * str); Geom::PathVector sp_svg_read_pathv (char const * str); gchar * sp_svg_write_path (const NArtBpath * bpath); gchar * sp_svg_write_path (Geom::PathVector const &p); +gchar * sp_svg_write_path (Geom::Path const &p); #endif -- 2.30.2