summaryrefslogtreecommitdiffstats
path: root/src/svg
diff options
context:
space:
mode:
authorLiam P. White <inkscapebrony@gmail.com>2014-10-18 21:44:39 +0000
committerLiam P. White <inkscapebrony@gmail.com>2014-10-18 21:44:39 +0000
commit68136c8b24a6995976db963a790207858e9baba5 (patch)
tree550e81af7c8d626ec80a2be5efec66dd10d84bc4 /src/svg
parentUpdate to experimental r13598 (diff)
parentUpdate to trunk r13621 (diff)
downloadinkscape-68136c8b24a6995976db963a790207858e9baba5.tar.gz
inkscape-68136c8b24a6995976db963a790207858e9baba5.zip
Update to experimental r13619
(bzr r13341.5.18)
Diffstat (limited to 'src/svg')
-rw-r--r--src/svg/CMakeLists.txt2
-rw-r--r--src/svg/Makefile_insert2
-rw-r--r--src/svg/svg-angle.cpp136
-rw-r--r--src/svg/svg-angle.h69
-rw-r--r--src/svg/svg-color.cpp4
5 files changed, 211 insertions, 2 deletions
diff --git a/src/svg/CMakeLists.txt b/src/svg/CMakeLists.txt
index 968287895..f9d0bc52d 100644
--- a/src/svg/CMakeLists.txt
+++ b/src/svg/CMakeLists.txt
@@ -7,6 +7,7 @@ set(svg_SRC
strip-trailing-zeros.cpp
svg-affine.cpp
svg-color.cpp
+ svg-angle.cpp
svg-length.cpp
svg-path.cpp
# test-stubs.cpp
@@ -24,6 +25,7 @@ set(svg_SRC
svg-color-test.h
svg-color.h
svg-icc-color.h
+ svg-angle.h
svg-length-test.h
svg-length.h
svg-path-geom-test.h
diff --git a/src/svg/Makefile_insert b/src/svg/Makefile_insert
index cf9bf3fbb..4f82bdd76 100644
--- a/src/svg/Makefile_insert
+++ b/src/svg/Makefile_insert
@@ -13,6 +13,8 @@ ink_common_sources += \
svg/svg-color.cpp \
svg/svg-color.h \
svg/svg-icc-color.h \
+ svg/svg-angle.cpp \
+ svg/svg-angle.h \
svg/svg-length.cpp \
svg/svg-length.h \
svg/svg-path.cpp \
diff --git a/src/svg/svg-angle.cpp b/src/svg/svg-angle.cpp
new file mode 100644
index 000000000..63152368e
--- /dev/null
+++ b/src/svg/svg-angle.cpp
@@ -0,0 +1,136 @@
+/**
+ * \file src/svg/svg-angle.cpp
+ * \brief SVG angle type
+ */
+/*
+ * Authors:
+ * Tomasz Boczkowski <penginsbacon@gmail.com>
+ *
+ * Copyright (C) 1999-2002 Lauris Kaplinski
+ * Copyright (C) 2000-2001 Ximian, Inc.
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <cstring>
+#include <string>
+#include <math.h>
+#include <glib.h>
+
+#include "svg.h"
+#include "stringstream.h"
+#include "svg/svg-angle.h"
+#include "util/units.h"
+
+
+static bool sp_svg_angle_read_lff(gchar const *str, SVGAngle::Unit &unit, float &val, float &computed);
+
+SVGAngle::SVGAngle()
+ : _set(false)
+ , unit(NONE)
+ , value(0)
+ , computed(0)
+{
+}
+
+/* Angle */
+
+bool SVGAngle::read(gchar const *str)
+{
+ if (!str) {
+ return false;
+ }
+
+ SVGAngle::Unit u;
+ float v;
+ float c;
+ if (!sp_svg_angle_read_lff(str, u, v, c)) {
+ return false;
+ }
+
+ _set = true;
+ unit = u;
+ value = v;
+ computed = c;
+
+ return true;
+}
+
+void SVGAngle::unset(SVGAngle::Unit u, float v, float c) {
+ _set = false;
+ unit = u;
+ value = v;
+ computed = c;
+}
+
+void SVGAngle::readOrUnset(gchar const *str, Unit u, float v, float c) {
+ if (!read(str)) {
+ unset(u, v, c);
+ }
+}
+
+static bool sp_svg_angle_read_lff(gchar const *str, SVGAngle::Unit &unit, float &val, float &computed)
+{
+ if (!str) {
+ return false;
+ }
+
+ gchar const *e;
+ float const v = g_ascii_strtod(str, (char **) &e);
+ if (e == str) {
+ return false;
+ }
+
+ if (!e[0]) {
+ /* Unitless (defaults to degrees)*/
+ unit = SVGAngle::NONE;
+ val = v;
+ computed = v;
+ return true;
+ } else if (!g_ascii_isalnum(e[0])) {
+ if (g_ascii_isspace(e[0]) && e[1] && g_ascii_isalpha(e[1])) {
+ return false; // spaces between value and unit are not allowed
+ } else {
+ /* Unitless (defaults to degrees)*/
+ unit = SVGAngle::NONE;
+ val = v;
+ computed = v;
+ return true;
+ }
+ } else {
+ if (strncmp(e, "deg", 3) == 0) {
+ unit = SVGAngle::DEG;
+ computed = v;
+ } else if (strncmp(e, "grad", 4) == 0) {
+ unit = SVGAngle::GRAD;
+ computed = Inkscape::Util::Quantity::convert(v, "grad", "°");
+ } else if (strncmp(e, "rad", 3) == 0) {
+ unit = SVGAngle::RAD;
+ computed = Inkscape::Util::Quantity::convert(v, "rad", "°");
+ } else if (strncmp(e, "turn", 4) == 0) {
+ unit = SVGAngle::TURN;
+ computed = Inkscape::Util::Quantity::convert(v, "turn", "°");
+ } else {
+ return false;
+ }
+ return true;
+ }
+
+ /* Invalid */
+ return false;
+}
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/svg/svg-angle.h b/src/svg/svg-angle.h
new file mode 100644
index 000000000..966491174
--- /dev/null
+++ b/src/svg/svg-angle.h
@@ -0,0 +1,69 @@
+#ifndef SEEN_SP_SVG_ANGLE_H
+#define SEEN_SP_SVG_ANGLE_H
+
+/**
+ * \file src/svg/svg-angle.h
+ * \brief SVG angle type
+ */
+/*
+ * Authors:
+ * Tomasz Boczkowski <penginsbacon@gmail.com>
+ *
+ * Copyright (C) 1999-2002 Lauris Kaplinski
+ * Copyright (C) 2000-2001 Ximian, Inc.
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include <glib.h>
+
+class SVGAngle
+{
+public:
+ SVGAngle();
+
+ enum Unit {
+ NONE,
+ DEG,
+ GRAD,
+ RAD,
+ TURN,
+ LAST_UNIT = TURN
+ };
+
+ // The object's value is valid / exists in SVG.
+ bool _set;
+
+ // The unit of value.
+ Unit unit;
+
+ // The value of this SVGAngle as found in the SVG.
+ float value;
+
+ // The value in degrees.
+ float computed;
+
+ float operator=(float v) {
+ _set = true;
+ unit = NONE;
+ value = computed = v;
+ return v;
+ }
+
+ bool read(gchar const *str);
+ void unset(Unit u = NONE, float v = 0, float c = 0);
+ void readOrUnset(gchar const *str, Unit u = NONE, float v = 0, float c = 0);
+};
+
+#endif // SEEN_SP_SVG_ANGLE_H
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/svg/svg-color.cpp b/src/svg/svg-color.cpp
index 5108b7702..c9f22f8a4 100644
--- a/src/svg/svg-color.cpp
+++ b/src/svg/svg-color.cpp
@@ -511,18 +511,18 @@ sp_svg_create_color_hash()
void icc_color_to_sRGB(SVGICCColor* icc, guchar* r, guchar* g, guchar* b)
{
- guchar color_out[4];
- guchar color_in[4];
if (icc) {
g_message("profile name: %s", icc->colorProfile.c_str());
Inkscape::ColorProfile* prof = SP_ACTIVE_DOCUMENT->profileManager->find(icc->colorProfile.c_str());
if ( prof ) {
+ guchar color_out[4] = {0,0,0,0};
cmsHTRANSFORM trans = prof->getTransfToSRGB8();
if ( trans ) {
std::vector<colorspace::Component> comps = colorspace::getColorSpaceInfo( prof );
size_t count = CMSSystem::getChannelCount( prof );
size_t cap = std::min(count, comps.size());
+ guchar color_in[4];
for (size_t i = 0; i < cap; i++) {
color_in[i] = static_cast<guchar>((((gdouble)icc->colors[i]) * 256.0) * (gdouble)comps[i].scale);
g_message("input[%d]: %d", (int)i, (int)color_in[i]);