Code

Filters. Some experimental filters improvements.
[inkscape.git] / src / extension / internal / filter / color.h
index 08ba4b475dc81e110505d619142089b42e6b0232..82a37a6aa787c250e20fba20522d9fb5097a9961 100644 (file)
@@ -39,6 +39,7 @@ public:
 //                 "<param name=\"tab\" type=\"notebook\">\n"
 //                    "<page name=\"Color1\" _gui-text=\"Color 1\">\n"
                         "<param name=\"fluo\" gui-text=\"" N_("Fluorescence") "\" type=\"boolean\">false</param>\n"
+                        "<param name=\"swapcolors\" gui-text=\"" N_("Swap colors") "\" type=\"boolean\">false</param>\n"
                         "<_param name=\"header1\" type=\"groupheader\">Color 1</_param>\n"
                                        "<param name=\"color1\" gui-text=\"" N_("Color 1") "\" type=\"color\">1364325887</param>\n"
 //                    "</page>\n"
@@ -75,10 +76,13 @@ Duochrome::get_filter_text (Inkscape::Extension::Extension * ext)
     std::ostringstream g2;
     std::ostringstream b2;
     std::ostringstream fluo;
+    std::ostringstream swapc;
 
     guint32 color1 = ext->get_param_color("color1");
     guint32 color2 = ext->get_param_color("color2");
     bool fluorescence = ext->get_param_bool("fluo");
+    bool swapcolors = ext->get_param_bool("swapcolors");
+
     a1 << (color1 & 0xff) / 255.0F;
     r1 << ((color1 >> 24) & 0xff);
     g1 << ((color1 >> 16) & 0xff);
@@ -87,24 +91,30 @@ Duochrome::get_filter_text (Inkscape::Extension::Extension * ext)
     r2 << ((color2 >> 24) & 0xff);
     g2 << ((color2 >> 16) & 0xff);
     b2 << ((color2 >>  8) & 0xff);
-    if (fluorescence) fluo << "";
-    else  fluo << " in=\"result6\"";
+    if (fluorescence)
+        fluo << "";
+    else
+        fluo << " in=\"blend\"";
+    if (swapcolors)
+        swapc << "in";
+    else
+        swapc << "out";
 
        _filter = g_strdup_printf(
                "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Duochrome, custom -EXP-\">\n"
             "<feColorMatrix type=\"luminanceToAlpha\" result=\"fbSourceGraphic\" />\n"
-            "<feFlood in=\"fbSourceGraphic\" flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"result1\" />\n"
-            "<feComposite in=\"result1\" in2=\"fbSourceGraphic\" operator=\"out\" result=\"result2\" />\n"
+            "<feFlood in=\"fbSourceGraphic\" flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"composite1\" />\n"
+            "<feComposite in=\"composite1\" in2=\"fbSourceGraphic\" operator=\"%s\" result=\"result2\" />\n"
             "<feComposite in2=\"SourceGraphic\" k2=\"1\" result=\"fbSourceGraphic\" operator=\"arithmetic\" />\n"
             "<feFlood in=\"fbSourceGraphic\" flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"result2\" />\n"
-            "<feMerge result=\"result5\">\n"
+            "<feMerge>\n"
                 "<feMergeNode in=\"result2\" />\n"
                 "<feMergeNode in=\"fbSourceGraphic\" />\n"
             "</feMerge>\n"
-            "<feBlend in2=\"fbSourceGraphic\" mode=\"normal\" blend=\"normal\" result=\"result6\" />\n"
-            "<feColorMatrix type=\"matrix\" values=\"2 -1 0 0 0 0 2 -1 0 0 -1 0 2 0 0 0 0 0 1 0 \" result=\"result10\" />\n"
+            "<feBlend in2=\"fbSourceGraphic\" mode=\"normal\" blend=\"normal\" result=\"blend\" />\n"
+            "<feColorMatrix type=\"matrix\" values=\"2 -1 0 0 0 0 2 -1 0 0 -1 0 2 0 0 0 0 0 1 0 \" />\n"
             "<feComposite %s in2=\"SourceGraphic\" operator=\"in\" result=\"fbSourceGraphic\" />\n"
-        "</filter>\n", a1.str().c_str(), r1.str().c_str(), g1.str().c_str(), b1.str().c_str(), a2.str().c_str(), r2.str().c_str(), g2.str().c_str(), b2.str().c_str(), fluo.str().c_str());
+        "</filter>\n", a1.str().c_str(), r1.str().c_str(), g1.str().c_str(), b1.str().c_str(), swapc.str().c_str(), a2.str().c_str(), r2.str().c_str(), g2.str().c_str(), b2.str().c_str(), fluo.str().c_str());
 
        return _filter;
 };