summaryrefslogtreecommitdiffstats
path: root/src/sp-solid-color.cpp
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2014-07-24 09:43:00 +0000
committertavmjong-free <tavmjong@free.fr>2014-07-24 09:43:00 +0000
commitb784997fa7a911f53b1ad9386f8ac631d85143b2 (patch)
treeda3b5f3105b59fcadefa47a1388fb5c1c52b1f95 /src/sp-solid-color.cpp
parentFix a bug on type of 'fillet' on the closing node (diff)
downloadinkscape-b784997fa7a911f53b1ad9386f8ac631d85143b2.tar.gz
inkscape-b784997fa7a911f53b1ad9386f8ac631d85143b2.zip
Basic support for <solidColor> element (rendring only as a paint server).
(bzr r13341.1.98)
Diffstat (limited to 'src/sp-solid-color.cpp')
-rw-r--r--src/sp-solid-color.cpp97
1 files changed, 97 insertions, 0 deletions
diff --git a/src/sp-solid-color.cpp b/src/sp-solid-color.cpp
new file mode 100644
index 000000000..1f606d176
--- /dev/null
+++ b/src/sp-solid-color.cpp
@@ -0,0 +1,97 @@
+/** @file
+ * @solid color class.
+ */
+/* Authors:
+ * Tavmjong Bah <tavjong@free.fr>
+ *
+ * Copyright (C) 2014 Tavmjong Bah
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+#include "sp-solid-color.h"
+
+#include "attributes.h"
+#include "style.h"
+#include "xml/repr.h"
+
+#include "sp-factory.h"
+#include "sp-item.h"
+#include "style-internal.h"
+
+namespace {
+ SPObject* createSolidColor() {
+ return new SPSolidColor();
+ }
+
+ bool solidColorRegistered = SPFactory::instance().registerObject("svg:solidColor", createSolidColor);
+}
+
+
+/*
+ * Solid Color
+ */
+SPSolidColor::SPSolidColor() : SPPaintServer() {
+}
+
+SPSolidColor::~SPSolidColor() {
+}
+
+void SPSolidColor::build(SPDocument* doc, Inkscape::XML::Node* repr) {
+ SPPaintServer::build(doc, repr);
+
+ this->readAttr( "style" );
+ this->readAttr( "solid-color" );
+ this->readAttr( "solid-opacity" );
+}
+
+/**
+ * Virtual build: set solidcolor attributes from its associated XML node.
+ */
+
+void SPSolidColor::set(unsigned int key, const gchar* value) {
+
+ if (SP_ATTRIBUTE_IS_CSS(key)) {
+ sp_style_read_from_object(this->style, this);
+ this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
+ } else {
+ SPPaintServer::set(key, value);
+ }
+}
+
+/**
+ * Virtual set: set attribute to value.
+ */
+
+Inkscape::XML::Node* SPSolidColor::write(Inkscape::XML::Document* xml_doc, Inkscape::XML::Node* repr, guint flags) {
+ if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
+ repr = xml_doc->createElement("svg:solidColor");
+ }
+
+ SPObject::write(xml_doc, repr, flags);
+
+ return repr;
+}
+
+cairo_pattern_t* SPSolidColor::pattern_new(cairo_t * /*ct*/, Geom::OptRect const &bbox, double opacity) {
+
+ SPIColor *c = &(this->style->solid_color);
+ cairo_pattern_t *cp = cairo_pattern_create_rgba ( c->value.color.v.c[0], c->value.color.v.c[1], c->value.color.v.c[2], SP_SCALE24_TO_FLOAT(this->style->solid_opacity.value) * opacity );
+
+ return cp;
+}
+
+
+/**
+ * Virtual write: write object attributes to repr.
+ */
+
+/*
+ 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 :