summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0436dd3)
raw | patch | inline | side by side (parent: 0436dd3)
author | buliabyak <buliabyak@users.sourceforge.net> | |
Tue, 31 Oct 2006 21:21:41 +0000 (21:21 +0000) | ||
committer | buliabyak <buliabyak@users.sourceforge.net> | |
Tue, 31 Oct 2006 21:21:41 +0000 (21:21 +0000) |
index e833157ed3f438c2fd1f9f0202dfd946776bc191..a76e6c19a2e6cec5c8d5db37bb67b0c7b6e90a70 100644 (file)
" ondark=\"4294967295\"" //ffffffff
" clips=\"16711935\"" // 00ff00ff
" masks=\"65535\"/>\n" // 0x0000ffff
+" <group id=\"svgoutput\" usenamedcolors=\"0\" numericprecision=\"8\" minimumexponent=\"-8\"/>\n"
" </group>\n"
"\n"
" <group id=\"extensions\">"
index 91b1cfcfb06378a7903c3a2791ce11856f40edb7..d59b8083ad4c2cb5fba6a9ed8f664e36387cec3c 100644 (file)
#include "svg/css-ostringstream.h"
#include "svg/strip-trailing-zeros.h"
+#include "prefs-utils.h"
#include <glib/gmessages.h>
#include <glib/gstrfuncs.h>
/* This one is (currently) needed though, as we currently use ostr.precision as a sort of
variable for storing the desired precision: see our two precision methods and our operator<<
methods for float and double. */
- ostr.precision(8);
+ ostr.precision(prefs_get_int_attribute("options.svgoutput", "numericprecision", 8));
}
static void
write_num(Inkscape::CSSOStringStream &os, unsigned const prec, double const d)
{
char buf[32]; // haven't thought about how much is really required.
- if (prec != 8) {
- static bool warned;
- if (!warned) {
- g_warning("Using precision of 8 instead of the requested %u. Won't re-warn.", prec);
- warned = true;
- }
+ switch (prec) {
+ case 10: g_ascii_formatd(buf, sizeof(buf), "%.10f", d);
+ case 9: g_ascii_formatd(buf, sizeof(buf), "%.9f", d);
+ case 8: g_ascii_formatd(buf, sizeof(buf), "%.8f", d);
+ case 7: g_ascii_formatd(buf, sizeof(buf), "%.7f", d);
+ case 6: g_ascii_formatd(buf, sizeof(buf), "%.6f", d);
+ case 5: g_ascii_formatd(buf, sizeof(buf), "%.5f", d);
+ case 4: g_ascii_formatd(buf, sizeof(buf), "%.4f", d);
+ case 3: g_ascii_formatd(buf, sizeof(buf), "%.3f", d);
+ case 2: g_ascii_formatd(buf, sizeof(buf), "%.2f", d);
+ case 1: g_ascii_formatd(buf, sizeof(buf), "%.1f", d);
+ case 0: g_ascii_formatd(buf, sizeof(buf), "%.0f", d);
}
- g_ascii_formatd(buf, sizeof(buf), "%.8f", d);
os << strip_trailing_zeros(buf);
}
index 5ef5c2ec06ddce94f6d2d1282b49920183f49107..cdb29c865e7cb7581c540f08c5a07faaf69dcaa0 100644 (file)
--- a/src/svg/stringstream.cpp
+++ b/src/svg/stringstream.cpp
#include "svg/stringstream.h"
#include "svg/strip-trailing-zeros.h"
+#include "prefs-utils.h"
Inkscape::SVGOStringStream::SVGOStringStream()
{
/* This one is (currently) needed though, as we currently use ostr.precision as a sort of
variable for storing the desired precision: see our two precision methods and our operator<<
methods for float and double. */
- ostr.precision(8);
+ ostr.precision(prefs_get_int_attribute("options.svgoutput", "numericprecision", 8));
}
Inkscape::SVGOStringStream &
diff --git a/src/svg/svg-affine.cpp b/src/svg/svg-affine.cpp
index 1c8b4211cf770521128b87848e21963e341e0e0a..6565b93538aa2cc80a9965523748c219744e9d00 100644 (file)
--- a/src/svg/svg-affine.cpp
+++ b/src/svg/svg-affine.cpp
#include <libnr/nr-translate-matrix-ops.h>
#include <libnr/nr-translate-rotate-ops.h>
#include "svg.h"
+#include "prefs-utils.h"
#ifndef M_PI
# define M_PI 3.14159265358979323846
@@ -174,6 +175,8 @@ sp_svg_transform_write(gchar str[], unsigned const size, NRMatrix const *transfo
}
e = 0.000001 * NR_MATRIX_DF_EXPANSION (transform);
+ int prec = prefs_get_int_attribute("options.svgoutput", "numericprecision", 8);
+ int min_exp = prefs_get_int_attribute("options.svgoutput", "minimumexponent", -8);
/* fixme: We could use t1 * t1 + t2 * t2 here instead */
if (NR_DF_TEST_CLOSE (transform->c[1], 0.0, e) && NR_DF_TEST_CLOSE (transform->c[2], 0.0, e)) {
@@ -188,9 +191,9 @@ sp_svg_transform_write(gchar str[], unsigned const size, NRMatrix const *transfo
unsigned p = 0;
strcpy (c + p, "scale(");
p += 6;
- p += sp_svg_number_write_de (c + p, transform->c[0], 6, -8, FALSE);
+ p += sp_svg_number_write_de (c + p, transform->c[0], prec, min_exp, FALSE);
c[p++] = ',';
- p += sp_svg_number_write_de (c + p, transform->c[3], 6, -8, FALSE);
+ p += sp_svg_number_write_de (c + p, transform->c[3], prec, min_exp, FALSE);
c[p++] = ')';
g_assert( p <= sizeof(c) );
p = MIN (p, size - 1 );
@@ -205,9 +208,9 @@ sp_svg_transform_write(gchar str[], unsigned const size, NRMatrix const *transfo
unsigned p = 0;
strcpy (c + p, "translate(");
p += 10;
- p += sp_svg_number_write_de (c + p, transform->c[4], 6, -8, FALSE);
+ p += sp_svg_number_write_de (c + p, transform->c[4], prec, min_exp, FALSE);
c[p++] = ',';
- p += sp_svg_number_write_de (c + p, transform->c[5], 6, -8, FALSE);
+ p += sp_svg_number_write_de (c + p, transform->c[5], prec, min_exp, FALSE);
c[p++] = ')';
g_assert( p <= sizeof(c) );
p = MIN(p, size - 1);
@@ -219,17 +222,17 @@ sp_svg_transform_write(gchar str[], unsigned const size, NRMatrix const *transfo
unsigned p = 0;
strcpy (c + p, "matrix(");
p += 7;
- p += sp_svg_number_write_de (c + p, transform->c[0], 6, -8, FALSE);
+ p += sp_svg_number_write_de (c + p, transform->c[0], prec, min_exp, FALSE);
c[p++] = ',';
- p += sp_svg_number_write_de (c + p, transform->c[1], 6, -8, FALSE);
+ p += sp_svg_number_write_de (c + p, transform->c[1], prec, min_exp, FALSE);
c[p++] = ',';
- p += sp_svg_number_write_de (c + p, transform->c[2], 6, -8, FALSE);
+ p += sp_svg_number_write_de (c + p, transform->c[2], prec, min_exp, FALSE);
c[p++] = ',';
- p += sp_svg_number_write_de (c + p, transform->c[3], 6, -8, FALSE);
+ p += sp_svg_number_write_de (c + p, transform->c[3], prec, min_exp, FALSE);
c[p++] = ',';
- p += sp_svg_number_write_de (c + p, transform->c[4], 6, -8, FALSE);
+ p += sp_svg_number_write_de (c + p, transform->c[4], prec, min_exp, FALSE);
c[p++] = ',';
- p += sp_svg_number_write_de (c + p, transform->c[5], 6, -8, FALSE);
+ p += sp_svg_number_write_de (c + p, transform->c[5], prec, min_exp, FALSE);
c[p++] = ')';
g_assert( p <= sizeof(c) );
p = MIN(p, size - 1);
@@ -243,17 +246,17 @@ sp_svg_transform_write(gchar str[], unsigned const size, NRMatrix const *transfo
unsigned p = 0;
strcpy (c + p, "matrix(");
p += 7;
- p += sp_svg_number_write_de (c + p, transform->c[0], 6, -8, FALSE);
+ p += sp_svg_number_write_de (c + p, transform->c[0], prec, min_exp, FALSE);
c[p++] = ',';
- p += sp_svg_number_write_de (c + p, transform->c[1], 6, -8, FALSE);
+ p += sp_svg_number_write_de (c + p, transform->c[1], prec, min_exp, FALSE);
c[p++] = ',';
- p += sp_svg_number_write_de (c + p, transform->c[2], 6, -8, FALSE);
+ p += sp_svg_number_write_de (c + p, transform->c[2], prec, min_exp, FALSE);
c[p++] = ',';
- p += sp_svg_number_write_de (c + p, transform->c[3], 6, -8, FALSE);
+ p += sp_svg_number_write_de (c + p, transform->c[3], prec, min_exp, FALSE);
c[p++] = ',';
- p += sp_svg_number_write_de (c + p, transform->c[4], 6, -8, FALSE);
+ p += sp_svg_number_write_de (c + p, transform->c[4], prec, min_exp, FALSE);
c[p++] = ',';
- p += sp_svg_number_write_de (c + p, transform->c[5], 6, -8, FALSE);
+ p += sp_svg_number_write_de (c + p, transform->c[5], prec, min_exp, FALSE);
c[p++] = ')';
g_assert( p <= sizeof(c) );
p = MIN(p, size - 1);
diff --git a/src/svg/svg-color.cpp b/src/svg/svg-color.cpp
index db2a891509ec282a5d6fef7567bd0e298f3f4f3a..57003064ace036aeeefd0d0ae26c0da0cebafd9b 100644 (file)
--- a/src/svg/svg-color.cpp
+++ b/src/svg/svg-color.cpp
# include "config.h"
#endif
+#include "prefs-utils.h"
#include "svg-color.h"
#include "svg-icc-color.h"
#include <cassert>
strcpy(buf, src);
}
- assert(sp_svg_read_color(buf, 0xff) == (rgb24 << 8));
+ // assert(sp_svg_read_color(buf, 0xff) == (rgb24 << 8));
}
/**
g_assert(8 <= buflen);
unsigned const rgb24 = rgba32 >> 8;
- rgb24_to_css(buf, rgb24);
+ if (prefs_get_int_attribute("options.svgoutput", "usenamedcolors", 0)) {
+ rgb24_to_css(buf, rgb24);
+ } else {
+ g_snprintf(buf, buflen, "#%06x", rgb24);
+ }
}
static GHashTable *