Code

Extensions. Removing tooltips from color>randomize (see Bug #676419).
authorJazzyNico <nicoduf@yahoo.fr>
Wed, 17 Nov 2010 19:57:36 +0000 (20:57 +0100)
committerJazzyNico <nicoduf@yahoo.fr>
Wed, 17 Nov 2010 19:57:36 +0000 (20:57 +0100)
Filters. Experimental filters cleanup.

share/extensions/color_randomize.inx
src/extension/internal/filter/color.h
src/extension/internal/filter/filter-all.cpp

index 8584722fa1239b1a180ba46784f67452a17c147b..82691f0f46c432446035695c9118a028b54111d8 100644 (file)
@@ -7,9 +7,9 @@
        <dependency type="executable" location="extensions">simplestyle.py</dependency>
        <param name="tab" type="notebook">
         <page name="Options" _gui-text="Options">
-               <param name="hue" type="boolean" _gui-text="Hue" _gui-description="Randomize hue">true</param>
-               <param name="saturation" type="boolean" _gui-text="Saturation" _gui-description="Randomize saturation">true</param>
-               <param name="lightness" type="boolean" _gui-text="Lightness" _gui-description="Randomize lightness">true</param>
+               <param name="hue" type="boolean" _gui-text="Hue">true</param>
+               <param name="saturation" type="boolean" _gui-text="Saturation">true</param>
+               <param name="lightness" type="boolean" _gui-text="Lightness">true</param>
         </page>
         <page name="Help" _gui-text="Help">
             <_param name="instructions" type="description" xml:space="preserve">Converts to HSL, randomizes hue and/or saturation and/or lightness and converts it back to RGB.</_param>
index 17815f0065177cb6b2a4e49e250c2784e6df0afb..1a1644276717099f41e749e0c244442a5c5e558c 100644 (file)
@@ -35,108 +35,13 @@ public:
                        "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
                                "<name>" N_("Duochrome, custom -EXP-") "</name>\n"
                                "<id>org.inkscape.effect.filter.Duochrome</id>\n"
-// Using color widgets in tabs makes Inkscape crash...
-//                 "<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"
-//                    "<page name=\"Color2\" _gui-text=\"Color 2\">\n"
-                        "<_param name=\"header2\" type=\"groupheader\">Color 2</_param>\n"
-                                       "<param name=\"color2\" gui-text=\"" N_("Color 2") "\" type=\"color\">-65281</param>\n"
-//                    "</page>\n"
-//                "</param>\n"
-                               "<effect>\n"
-                                       "<object-type>all</object-type>\n"
-                                       "<effects-menu>\n"
-                                               "<submenu name=\"" N_("Filters") "\">\n"
-                                               "<submenu name=\"" N_("Experimental") "\"/>\n"
-                             "</submenu>\n"
-                                       "</effects-menu>\n"
-                                       "<menu-tip>" N_("Change colors to a two colors palette") "</menu-tip>\n"
-                               "</effect>\n"
-                       "</inkscape-extension>\n", new Duochrome());
-       };
-
-};
-
-gchar const *
-Duochrome::get_filter_text (Inkscape::Extension::Extension * ext)
-{
-       if (_filter != NULL) g_free((void *)_filter);
-
-    std::ostringstream a1;
-    std::ostringstream r1;
-    std::ostringstream g1;
-    std::ostringstream b1;
-    std::ostringstream a2;
-    std::ostringstream r2;
-    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);
-    b1 << ((color1 >>  8) & 0xff);
-    a2 << (color2 & 0xff) / 255.0F;
-    r2 << ((color2 >> 24) & 0xff);
-    g2 << ((color2 >> 16) & 0xff);
-    b2 << ((color2 >>  8) & 0xff);
-    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=\"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>\n"
-                "<feMergeNode in=\"result2\" />\n"
-                "<feMergeNode in=\"fbSourceGraphic\" />\n"
-            "</feMerge>\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(), 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;
-};
-
-
-class Duochrome2 : public Inkscape::Extension::Internal::Filter::Filter {
-protected:
-       virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
-
-public:
-       Duochrome2 ( ) : Filter() { };
-       virtual ~Duochrome2 ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
-
-       static void init (void) {
-               Inkscape::Extension::build_from_mem(
-                       "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
-                               "<name>" N_("Duochrome2, custom -EXP-") "</name>\n"
-                               "<id>org.inkscape.effect.filter.Duochrome2</id>\n"
                         "<param name=\"fluo\" gui-text=\"" N_("Fluorescence level:") "\" type=\"float\" min=\"0\" max=\"2\">0</param>\n"
-                        "<param name=\"pres1\" gui-text=\"" N_("Presence 1:") "\" type=\"float\" min=\"0\" max=\"2\">1</param>\n"
-                        "<param name=\"pres2\" gui-text=\"" N_("Presence 2:") "\" type=\"float\" min=\"0\" max=\"2\">1</param>\n"
-                        "<param name=\"swapcolors\" gui-text=\"" N_("Swap colors") "\" type=\"boolean\">false</param>\n"
+                        "<param name=\"swap\" gui-text=\"" N_("Swap:") "\" type=\"enum\">\n"
+                            "<_item value=\"none\">No swap</_item>\n"
+                            "<_item value=\"full\">Color and alpha</_item>\n"
+                            "<_item value=\"color\">Color only</_item>\n"
+                            "<_item value=\"alpha\">Alpha only</_item>\n"
+                        "</param>\n"
                         "<_param name=\"header1\" type=\"groupheader\">Color 1</_param>\n"
                                        "<param name=\"color1\" gui-text=\"" N_("Color 1") "\" type=\"color\">1364325887</param>\n"
                         "<_param name=\"header2\" type=\"groupheader\">Color 2</_param>\n"
@@ -150,13 +55,13 @@ public:
                                        "</effects-menu>\n"
                                        "<menu-tip>" N_("Convert luminance values to a duochrome palette") "</menu-tip>\n"
                                "</effect>\n"
-                       "</inkscape-extension>\n", new Duochrome2());
+                       "</inkscape-extension>\n", new Duochrome());
        };
 
 };
 
 gchar const *
-Duochrome2::get_filter_text (Inkscape::Extension::Extension * ext)
+Duochrome::get_filter_text (Inkscape::Extension::Extension * ext)
 {
        if (_filter != NULL) g_free((void *)_filter);
 
@@ -169,51 +74,56 @@ Duochrome2::get_filter_text (Inkscape::Extension::Extension * ext)
     std::ostringstream g2;
     std::ostringstream b2;
     std::ostringstream fluo;
-    std::ostringstream pres1;
-    std::ostringstream pres2;
     std::ostringstream swap1;
     std::ostringstream swap2;
-
     guint32 color1 = ext->get_param_color("color1");
     guint32 color2 = ext->get_param_color("color2");
     float fluorescence = ext->get_param_float("fluo");
-    float presence1 = ext->get_param_float("pres1");
-    float presence2 = ext->get_param_float("pres2");
-    bool swapcolors = ext->get_param_bool("swapcolors");
+    const gchar *swaptype = ext->get_param_enum("swap");
 
-    a1 << (color1 & 0xff) / 255.0F;
     r1 << ((color1 >> 24) & 0xff);
     g1 << ((color1 >> 16) & 0xff);
     b1 << ((color1 >>  8) & 0xff);
-    a2 << (color2 & 0xff) / 255.0F;
     r2 << ((color2 >> 24) & 0xff);
     g2 << ((color2 >> 16) & 0xff);
     b2 << ((color2 >>  8) & 0xff);
     fluo << fluorescence;
-    pres1 << presence1;
-    pres2 << presence2;
 
-    if (swapcolors) {
+    if((g_ascii_strcasecmp("full", swaptype) == 0)) {
         swap1 << "in";
         swap2 << "out";
-    } else {
+        a1 << (color1 & 0xff) / 255.0F;
+        a2 << (color2 & 0xff) / 255.0F;
+    } else if((g_ascii_strcasecmp("color", swaptype) == 0)) {
+        swap1 << "in";
+        swap2 << "out";
+        a1 << (color2 & 0xff) / 255.0F;
+        a2 << (color1 & 0xff) / 255.0F;
+    } else if((g_ascii_strcasecmp("alpha", swaptype) == 0)) {
+        swap1 << "out";
         swap2 << "in";
+        a1 << (color2 & 0xff) / 255.0F;
+        a2 << (color1 & 0xff) / 255.0F;
+    } else {
         swap1 << "out";
+        swap2 << "in";
+        a1 << (color1 & 0xff) / 255.0F;
+        a2 << (color2 & 0xff) / 255.0F;
     }
 
        _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=\"Duochrome2, custom -EXP-\">\n"
+               "<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=\"colormatrix1\" />\n"
             "<feFlood flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood1\" />\n"
             "<feComposite in2=\"colormatrix1\" operator=\"%s\" result=\"composite1\" />\n"
             "<feFlood in=\"colormatrix1\" flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood2\" />\n"
             "<feComposite in2=\"colormatrix1\" result=\"composite2\" operator=\"%s\" />\n"
-            "<feComposite in=\"composite2\" in2=\"composite1\" k2=\"%s\"  k3=\"%s\" operator=\"arithmetic\" result=\"composite3\" />\n"
+            "<feComposite in=\"composite2\" in2=\"composite1\" k2=\"1\"  k3=\"1\" operator=\"arithmetic\" result=\"composite3\" />\n"
             "<feColorMatrix in=\"composite3\" type=\"matrix\" values=\"2 -1 0 0 0 0 2 -1 0 0 -1 0 2 0 0 0 0 0 1 0 \" result=\"colormatrix2\" />\n"
             "<feComposite in=\"colormatrix2\" in2=\"composite3\" operator=\"arithmetic\" k2=\"%s\" result=\"composite4\" />\n"
             "<feBlend in=\"composite4\" in2=\"composite3\" blend=\"normal\" mode=\"normal\" result=\"blend\" />\n"
             "<feComposite in2=\"SourceGraphic\" operator=\"in\" />\n"
-        "</filter>\n", a1.str().c_str(), r1.str().c_str(), g1.str().c_str(), b1.str().c_str(), swap1.str().c_str(), a2.str().c_str(), r2.str().c_str(), g2.str().c_str(), b2.str().c_str(), swap2.str().c_str(), pres2.str().c_str(), pres1.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(), swap1.str().c_str(), a2.str().c_str(), r2.str().c_str(), g2.str().c_str(), b2.str().c_str(), swap2.str().c_str(), fluo.str().c_str());
 
        return _filter;
 };
index 287d0a097fdc68660ad1baad9028b428548610c9..6920e1bacbf7e75ad9b5a8bb4fed278aa2a6c136 100644 (file)
@@ -24,7 +24,6 @@ Filter::filters_all (void )
 {
        // Here come the filters which are coded in C++ in order to present a parameters dialog
     Duochrome::init();
-    Duochrome2::init();
        DropShadow::init();
        DropGlow::init();
     ColorizableDropShadow::init();