diff options
| author | Nicolas Dufour <nicoduf@yahoo.fr> | 2010-11-28 19:09:00 +0000 |
|---|---|---|
| committer | JazzyNico <nicoduf@yahoo.fr> | 2010-11-28 19:09:00 +0000 |
| commit | 29a2ba269e0abf7144c519c9c83edc79b5ebfb0a (patch) | |
| tree | 958ea7614417b2fda6e6510feabe8feacb079e8c /src | |
| parent | Japanese tutorials update (diff) | |
| download | inkscape-29a2ba269e0abf7144c519c9c83edc79b5ebfb0a.tar.gz inkscape-29a2ba269e0abf7144c519c9c83edc79b5ebfb0a.zip | |
Filters. New custom predefined Drawing filter (experimental, and currently a bit tall), and some tweaks and fixes.
(bzr r9931)
Diffstat (limited to 'src')
| -rw-r--r-- | src/extension/internal/filter/color.h | 10 | ||||
| -rw-r--r-- | src/extension/internal/filter/experimental.h | 168 | ||||
| -rw-r--r-- | src/extension/internal/filter/filter-all.cpp | 3 | ||||
| -rw-r--r-- | src/extension/internal/filter/morphology.h | 36 |
4 files changed, 185 insertions, 32 deletions
diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index d9720b05c..3bf2f6307 100644 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -52,7 +52,6 @@ public: "<param name=\"hlight\" gui-text=\"" N_("Harsh light:") "\" type=\"float\" min=\"0\" max=\"10\">0</param>\n" "<param name=\"nlight\" gui-text=\"" N_("Normal light:") "\" type=\"float\" min=\"0\" max=\"10\">1</param>\n" "<param name=\"duotone\" gui-text=\"" N_("Duotone") "\" type=\"boolean\" >false</param>\n" - "<param name=\"fg\" gui-text=\"" N_("Filtered greys") "\" type=\"boolean\" >false</param>\n" "<param name=\"blend1\" gui-text=\"" N_("Blend1:") "\" type=\"enum\">\n" "<_item value=\"multiply\">Multiply</_item>\n" "<_item value=\"normal\">Normal</_item>\n" @@ -94,7 +93,6 @@ Colorize::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream hlight; std::ostringstream nlight; std::ostringstream duotone; - std::ostringstream fg; std::ostringstream blend1; std::ostringstream blend2; @@ -112,10 +110,6 @@ Colorize::get_filter_text (Inkscape::Extension::Extension * ext) duotone << "0"; else duotone << "1"; - if (ext->get_param_bool("fg")) - fg << "0"; - else - fg << "1"; _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=\"Colorize, custom -EXP-\">\n" @@ -124,9 +118,9 @@ Colorize::get_filter_text (Inkscape::Extension::Extension * ext) "<feFlood flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood1\" />\n" "<feBlend in=\"flood1\" in2=\"colormatrix1\" mode=\"%s\" result=\"blend1\" />\n" "<feBlend in2=\"blend1\" mode=\"%s\" result=\"blend2\" />\n" - "<feColorMatrix in=\"blend2\" values=\"%s\" type=\"saturate\" result=\"colormatrix2\" />\n" + "<feColorMatrix in=\"blend2\" values=\"1\" type=\"saturate\" result=\"colormatrix2\" />\n" "<feComposite in=\"colormatrix2\" in2=\"SourceGraphic\" operator=\"in\" k2=\"1\" result=\"composite2\" />\n" - "</filter>\n", hlight.str().c_str(), nlight.str().c_str(), duotone.str().c_str(), a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), blend1.str().c_str(), blend2.str().c_str(), fg.str().c_str()); + "</filter>\n", hlight.str().c_str(), nlight.str().c_str(), duotone.str().c_str(), a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), blend1.str().c_str(), blend2.str().c_str()); return _filter; }; /* Colorize filter */ diff --git a/src/extension/internal/filter/experimental.h b/src/extension/internal/filter/experimental.h index 7bf27bee8..6acf59f82 100644 --- a/src/extension/internal/filter/experimental.h +++ b/src/extension/internal/filter/experimental.h @@ -22,6 +22,169 @@ namespace Extension { namespace Internal { namespace Filter { +/** + \brief Custom predefined Drawing filter. + + Convert images to duochrome drawings. + + Filter's parameters: + * Simplification (0.01->10, default 0.7) -> blur1 (stdDeviation) + * Lightness (0->50, default 5) -> convolve (kernelMatrix, central value -1000->-1050, default -1005) + * Smoothness (0.01->10, default 0.7) -> blur2 (stdDeviation) + * Dilatation (3->100, default 6) -> colormatrix3 (n-1th value) + + * Blur (0.01->10., default 5.) -> blur3 (stdDeviation) + * Blur spread (3->20, default 6) -> colormatrix5 (n-1th value) + * Blur erosion (-2->0, default -2) -> colormatrix5 (nth value) + + * Stroke color (guint, default 205,0,0) -> flood2 (flood-opacity, flood-color) + * Image on stroke (boolean, default false) -> composite1 (in="flood2" true-> in="SourceGraphic") + * Image on stroke opacity (0.->1., default 1) -> composite3 (k3) + * Fill color (guint, default 255,203,0) -> flood3 (flood-opacity, flood-color) + * Image on fill (boolean, default false) -> composite2 (in="flood3" true-> in="SourceGraphic") + * Image on fill opacity (0.->1., default 1) -> composite3 (k2) +*/ + +class Drawing : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + Drawing ( ) : Filter() { }; + virtual ~Drawing ( ) { 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_("Drawing, custom -EXP-") "</name>\n" + "<id>org.inkscape.effect.filter.Drawing</id>\n" + "<param name=\"simply\" gui-text=\"" N_("Simplification:") "\" type=\"float\" min=\"0.01\" max=\"10\">0.7</param>\n" + "<param name=\"light\" gui-text=\"" N_("Lightness:") "\" type=\"int\" min=\"0\" max=\"50\">5</param>\n" + "<param name=\"smooth\" gui-text=\"" N_("Smoothness:") "\" type=\"float\" min=\"0.01\" max=\"10\">0.7</param>\n" + "<param name=\"dilat\" gui-text=\"" N_("Dilatation:") "\" type=\"int\" min=\"3\" max=\"100\">6</param>\n" + "<param name=\"blur\" gui-text=\"" N_("Blur:") "\" type=\"float\" min=\"0.01\" max=\"10\">5</param>\n" + "<param name=\"spread\" gui-text=\"" N_("Spread:") "\" type=\"int\" min=\"3\" max=\"20\">6</param>\n" + "<param name=\"erosion\" gui-text=\"" N_("Erosion:") "\" type=\"int\" min=\"-2\" max=\"0\">-2</param>\n" + "<_param name=\"fillcolorheader\" type=\"groupheader\">Fill color</_param>\n" + "<param name=\"fcolor\" gui-text=\"" N_("Fill color") "\" type=\"color\">-3473153</param>\n" + "<param name=\"iof\" gui-text=\"" N_("Image on fill") "\" type=\"boolean\" >false</param>\n" + "<param name=\"iofo\" gui-text=\"" N_("Image on fill opacity:") "\" type=\"float\" min=\"0\" max=\"1\">1</param>\n" + "<_param name=\"strokecolorheader\" type=\"groupheader\">Stroke color</_param>\n" + "<param name=\"scolor\" gui-text=\"" N_("Stroke color") "\" type=\"color\">-855637761</param>\n" + "<param name=\"ios\" gui-text=\"" N_("Image on stroke") "\" type=\"boolean\" >false</param>\n" + "<param name=\"ioso\" gui-text=\"" N_("Image on stroke opacity:") "\" type=\"float\" min=\"0\" max=\"1\">1</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_("Convert images to duochrome drawings") "</menu-tip>\n" + "</effect>\n" + "</inkscape-extension>\n", new Drawing()); + }; + +}; + +gchar const * +Drawing::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream simply; + std::ostringstream light; + std::ostringstream smooth; + std::ostringstream dilat; + std::ostringstream blur; + std::ostringstream spread; + std::ostringstream erosion; + std::ostringstream strokea; + std::ostringstream stroker; + std::ostringstream strokeg; + std::ostringstream strokeb; + std::ostringstream ios; + std::ostringstream ioso; + std::ostringstream filla; + std::ostringstream fillr; + std::ostringstream fillg; + std::ostringstream fillb; + std::ostringstream iof; + std::ostringstream iofo; + + simply << ext->get_param_float("simply"); + light << (-1000 - ext->get_param_int("light")); + smooth << ext->get_param_float("smooth"); + dilat << ext->get_param_int("dilat"); + + blur << ext->get_param_float("blur"); + spread << ext->get_param_int("spread"); + erosion << ext->get_param_int("erosion"); + + guint32 fcolor = ext->get_param_color("fcolor"); + fillr << ((fcolor >> 24) & 0xff); + fillg << ((fcolor >> 16) & 0xff); + fillb << ((fcolor >> 8) & 0xff); + filla << (fcolor & 0xff) / 255.0F; + if (ext->get_param_bool("iof")) + iof << "SourceGraphic"; + else + iof << "flood3"; + iofo << ext->get_param_float("iofo"); + + guint32 scolor = ext->get_param_color("scolor"); + stroker << ((scolor >> 24) & 0xff); + strokeg << ((scolor >> 16) & 0xff); + strokeb << ((scolor >> 8) & 0xff); + strokea << (scolor & 0xff) / 255.0F; + if (ext->get_param_bool("ios")) + ios << "SourceGraphic"; + else + ios << "flood2"; + ioso << ext->get_param_float("ioso"); + + _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=\"Cross-smooth, custom -EXP-\">\n" + "<feGaussianBlur in=\"SourceGraphic\" stdDeviation=\"%s\" result=\"blur1\" />\n" + "<feConvolveMatrix in=\"blur1\" order=\"3 3\" kernelMatrix=\"0 250 0 250 %s 250 0 250 0 \" divisor=\"1\" targetX=\"1\" targetY=\"1\" preserveAlpha=\"true\" bias=\"0\" stdDeviation=\"1\" result=\"convolve\" />\n" + "<feColorMatrix values=\"0 -100 0 0 1 0 -100 0 0 1 0 -100 0 0 1 0 0 0 1 0 \" result=\"colormatrix1\" />\n" + "<feColorMatrix in=\"colormatrix1\" values=\"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.2125 -0.7154 -0.0721 1 0 \" result=\"colormatrix2\" />\n" + "<feGaussianBlur stdDeviation=\"%s\" result=\"blur2\" />\n" + "<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 %s -2 \" result=\"colormatrix3\" />\n" + "<feFlood flood-color=\"rgb(255,255,255)\" result=\"flood1\" />\n" + "<feBlend in2=\"colormatrix3\" blend=\"normal\" mode=\"multiply\" result=\"blend1\" />\n" + "<feComponentTransfer in=\"blend1\" result=\"component1\">\n" + "<feFuncR tableValues=\"0 1 1\" type=\"discrete\" />\n" + "<feFuncG tableValues=\"0 1 1\" type=\"discrete\" />\n" + "<feFuncB tableValues=\"0 1 1\" type=\"discrete\" />\n" + "</feComponentTransfer>\n" + "<feGaussianBlur stdDeviation=\"%s\" result=\"blur3\" />\n" + "<feColorMatrix in=\"blur3\" values=\"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.2125 -0.7154 -0.0721 1 0 \" result=\"colormatrix4\" />\n" + "<feColorMatrix stdDeviation=\"3\" values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 %s %s \" result=\"colormatrix5\" />\n" + "<feColorMatrix in=\"colormatrix5\" type=\"saturate\" values=\"1\" result=\"colormatrix6\" />\n" + "<feFlood flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" stdDeviation=\"3\" result=\"flood2\" />\n" + "<feComposite in=\"%s\" in2=\"colormatrix6\" operator=\"in\" result=\"composite1\" />\n" + "<feFlood flood-opacity=\"%s\" in=\"colormatrix6\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood3\" />\n" + "<feComposite in=\"%s\" in2=\"colormatrix6\" operator=\"out\" result=\"composite2\" />\n" + "<feComposite in2=\"composite1\" operator=\"arithmetic\" k2=\"%s\" k3=\"%s\" result=\"composite3\" />\n" + "<feComposite in2=\"SourceGraphic\" operator=\"in\" />\n" + "</filter>\n", simply.str().c_str(), light.str().c_str(), smooth.str().c_str(), dilat.str().c_str(), blur.str().c_str(), spread.str().c_str(), erosion.str().c_str(), strokea.str().c_str(), stroker.str().c_str(), strokeg.str().c_str(), strokeb.str().c_str(), ios.str().c_str(), filla.str().c_str(), fillr.str().c_str(), fillg.str().c_str(), fillb.str().c_str(), iof.str().c_str(), iofo.str().c_str(), ioso.str().c_str()); + + return _filter; +}; /* Drawing filter */ + +/** + \brief Custom predefined Posterize filter. + + Poster and painting effects. + + Filter's parameters: + * Type (enum, default "Normal") -> + Normal = feComponentTransfer + Dented = Normal + intermediate values + * Blur (0.01->10., default 5.) -> blur3 (stdDeviation) + +*/ class Posterize : public Inkscape::Extension::Internal::Filter::Filter { protected: virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); @@ -90,7 +253,7 @@ Posterize::get_filter_text (Inkscape::Extension::Extension * ext) postsat << ext->get_param_float("postsaturation"); - // TransfertComponenet table values are calculated based on the poster type. + // TransfertComponent table values are calculated based on the poster type. transf << "0"; int levels = ext->get_param_int("levels") + 1; const gchar *effecttype = ext->get_param_enum("type"); @@ -128,7 +291,8 @@ Posterize::get_filter_text (Inkscape::Extension::Extension * ext) "</filter>\n", blur1.str().c_str(), blur2.str().c_str(), blendmode.str().c_str(), presat.str().c_str(), table.str().c_str(), transf.str().c_str(), table.str().c_str(), transf.str().c_str(), table.str().c_str(), transf.str().c_str(), postsat.str().c_str(), antialias.str().c_str()); return _filter; -}; +}; /* Posterize filter */ + class TestFilter : public Inkscape::Extension::Internal::Filter::Filter { protected: diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp index 80fa7c69e..d04e423ff 100644 --- a/src/extension/internal/filter/filter-all.cpp +++ b/src/extension/internal/filter/filter-all.cpp @@ -37,7 +37,7 @@ Filter::filters_all (void ) Quadritone::init(); Solarize::init(); Tritone::init(); - + // Morphology Crosssmooth::init(); @@ -45,6 +45,7 @@ Filter::filters_all (void ) ColorizableDropShadow::init(); // TDB + Drawing::init(); Posterize::init(); // Here come the rest of the filters that are read from SVG files in share/filters and diff --git a/src/extension/internal/filter/morphology.h b/src/extension/internal/filter/morphology.h index 61fb8d42b..e0f544c76 100644 --- a/src/extension/internal/filter/morphology.h +++ b/src/extension/internal/filter/morphology.h @@ -28,12 +28,10 @@ namespace Filter { Smooth the outside of shapes and pictures. Filter's parameters: - * Type (enum, default "Smooth all") -> - Smooth all = composite (in="colormatrix", in2="colormatrix") - Smooth edges = composite (in="SourceGraphic", in2="colormatrix") + * Type (enum, default "Smooth edges") -> + Smooth edges = composite1 (in="SourceGraphic", in2="blur") + Smooth all = composite1 (in="blur", in2="blur") * Blur (0.01->10., default 5.) -> blur (stdDeviation) - * Spreading (1->100, default 20) -> colormatrix (value n-1) - * Erosion (0->-100, default -15) -> colormatrix (value n) */ class Crosssmooth : public Inkscape::Extension::Internal::Filter::Filter { @@ -50,12 +48,10 @@ public: "<name>" N_("Cross-smooth, custom -EXP-") "</name>\n" "<id>org.inkscape.effect.filter.Crosssmooth</id>\n" "<param name=\"type\" gui-text=\"" N_("Type:") "\" type=\"enum\">\n" - "<_item value=\"all\">Smooth all</_item>\n" "<_item value=\"edges\">Smooth edges</_item>\n" + "<_item value=\"all\">Smooth all</_item>\n" "</param>\n" "<param name=\"blur\" gui-text=\"" N_("Blur:") "\" type=\"float\" min=\"0.01\" max=\"10\">5</param>\n" - "<param name=\"spreading\" gui-text=\"" N_("Spreading:") "\" type=\"int\" min=\"1\" max=\"100\">20</param>\n" - "<param name=\"erosion\" gui-text=\"" N_("Erosion:") "\" type=\"int\" min=\"-100\" max=\"0\">-15</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" @@ -63,7 +59,7 @@ public: "<submenu name=\"" N_("Experimental") "\"/>\n" "</submenu>\n" "</effects-menu>\n" - "<menu-tip>" N_("Smooth the outside of shapes and pictures without altering their contents") "</menu-tip>\n" + "<menu-tip>" N_("Smooth edges and angles of shapes") "</menu-tip>\n" "</effect>\n" "</inkscape-extension>\n", new Crosssmooth()); }; @@ -76,27 +72,25 @@ Crosssmooth::get_filter_text (Inkscape::Extension::Extension * ext) if (_filter != NULL) g_free((void *)_filter); std::ostringstream blur; - std::ostringstream spreading; - std::ostringstream erosion; - std::ostringstream cin; + std::ostringstream c1in; blur << ext->get_param_float("blur"); - spreading << ext->get_param_int("spreading"); - erosion << ext->get_param_int("erosion"); const gchar *type = ext->get_param_enum("type"); if((g_ascii_strcasecmp("all", type) == 0)) { - cin << "colormatrix"; + c1in << "blur"; } else { - cin << "SourceGraphic"; + c1in << "SourceGraphic"; } - + _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=\"Cross-smooth, custom -EXP-\">\n" + "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" y=\"0\" x=\"0\" inkscape:label=\"Cross-smooth, custom -EXP-\">\n" "<feGaussianBlur stdDeviation=\"%s\" result=\"blur\" />\n" - "<feColorMatrix in=\"blur\" values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 %s %s \" result=\"colormatrix\" />\n" - "<feComposite in=\"%s\" in2=\"colormatrix\" operator=\"in\" />\n" - "</filter>\n", blur.str().c_str(), spreading.str().c_str(), erosion.str().c_str(), cin.str().c_str()); + "<feComposite in=\"%s\" in2=\"blur\" operator=\"atop\" result=\"composite1\" />\n" + "<feComposite in2=\"composite1\" operator=\"in\" result=\"composite2\" />\n" + "<feComposite in2=\"composite2\" operator=\"in\" result=\"composite3\" />\n" + "<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -10 \" result=\"colormatrix\" />\n" + "</filter>\n", blur.str().c_str(), c1in.str().c_str()); return _filter; }; /* Crosssmooth filter */ |
