Code

Correcting black gradient stops when swatches are set or drug.
[inkscape.git] / src / sp-stop.cpp
index 740cfef7853e49dc0eedf63a13ea247ccb08d388..031c6a3ea8f00060f855c6c928de6ee031fd4061 100644 (file)
@@ -15,7 +15,7 @@
 
 
 #include "sp-stop.h"
-
+#include "style.h"
 
 // A stop might have some non-stop siblings
 SPStop* SPStop::getNextStop()
@@ -52,6 +52,33 @@ SPStop* SPStop::getPrevStop()
     return result;
 }
 
+SPColor SPStop::readStopColor( Glib::ustring const &styleStr, guint32 dfl )
+{
+    SPColor color(dfl);
+    SPStyle style;
+    SPIPaint paint;
+    paint.read( styleStr.c_str(), style );
+    if ( paint.isColor() ) {
+        color = paint.value.color;
+    }
+    return color;
+}
+
+SPColor SPStop::getEffectiveColor() const
+{
+    SPColor ret;
+    if (currentColor) {
+        char const *str = sp_object_get_style_property(this, "color", NULL);
+        /* Default value: arbitrarily black.  (SVG1.1 and CSS2 both say that the initial
+         * value depends on user agent, and don't give any further restrictions that I can
+         * see.) */
+        ret = readStopColor( str, 0 );
+    } else {
+        ret = specified_color;
+    }
+    return ret;
+}
+
 
 
 /*