diff options
| author | Nicolas Dufour <nicoduf@yahoo.fr> | 2011-08-09 20:29:53 +0000 |
|---|---|---|
| committer | JazzyNico <nicoduf@yahoo.fr> | 2011-08-09 20:29:53 +0000 |
| commit | df08cc238f064ebdac402a4c9abd7e1737e0d274 (patch) | |
| tree | 78ff92c712e9bf204f859aef5810dd875be56e61 /src | |
| parent | Remove unused variable. (diff) | |
| download | inkscape-df08cc238f064ebdac402a4c9abd7e1737e0d274.tar.gz inkscape-df08cc238f064ebdac402a4c9abd7e1737e0d274.zip | |
Filters. New Invert, Wax bump and Felt feather custom predefined filters.
Filters. More reorganization and consistency fixes.
(bzr r10533)
Diffstat (limited to 'src')
| -rw-r--r-- | src/extension/internal/filter/blurs.h | 10 | ||||
| -rw-r--r-- | src/extension/internal/filter/bumps.h | 220 | ||||
| -rw-r--r-- | src/extension/internal/filter/color.h | 164 | ||||
| -rw-r--r-- | src/extension/internal/filter/distort.h | 146 | ||||
| -rwxr-xr-x | src/extension/internal/filter/filter-all.cpp | 9 | ||||
| -rw-r--r-- | src/extension/internal/filter/paint.h | 7 |
6 files changed, 527 insertions, 29 deletions
diff --git a/src/extension/internal/filter/blurs.h b/src/extension/internal/filter/blurs.h index b09a4f347..b8a6d7c4c 100644 --- a/src/extension/internal/filter/blurs.h +++ b/src/extension/internal/filter/blurs.h @@ -12,7 +12,7 @@ * Clean edges * Cross blur * Feather - * Image blur + * Out of focus * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -280,7 +280,7 @@ Feather::get_filter_text (Inkscape::Extension::Extension * ext) }; /* Feather filter */ /** - \brief Custom predefined Image blur filter. + \brief Custom predefined Out of Focus filter. Blur eroded by white or transparency @@ -307,7 +307,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" - "<name>" N_("Image Blur") "</name>\n" + "<name>" N_("Out of Focus") "</name>\n" "<id>org.inkscape.effect.filter.ImageBlur</id>\n" "<param name=\"tab\" type=\"notebook\">\n" "<page name=\"optionstab\" _gui-text=\"Options\">\n" @@ -380,7 +380,7 @@ ImageBlur::get_filter_text (Inkscape::Extension::Extension * ext) } _filter = g_strdup_printf( - "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Image Blur\">\n" + "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Out of Focus\">\n" "<feFlood flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood\" />\n" "<feColorMatrix in=\"SourceGraphic\" values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 -0.2125 -0.7154 -0.0721 1 0 \" result=\"colormatrix1\" />\n" "<feGaussianBlur in=\"colormatrix1\" stdDeviation=\"%s %s\" result=\"blur\" />\n" @@ -393,7 +393,7 @@ ImageBlur::get_filter_text (Inkscape::Extension::Extension * ext) background.str().c_str(), blend.str().c_str(), opacity.str().c_str()); return _filter; -}; /* Image blur filter */ +}; /* Out of Focus filter */ }; /* namespace Filter */ }; /* namespace Internal */ diff --git a/src/extension/internal/filter/bumps.h b/src/extension/internal/filter/bumps.h index e8c80315a..9d46a25b2 100644 --- a/src/extension/internal/filter/bumps.h +++ b/src/extension/internal/filter/bumps.h @@ -12,6 +12,7 @@ * Diffuse light * Matte jelly * Specular light + * Wax bump * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -37,7 +38,7 @@ namespace Filter { Options * Image simplification (0.01->10., default 0.01) -> blur1 (stdDeviation) * Bump simplification (0.01->10., default 0.01) -> blur2 (stdDeviation) - * Crop (-50.->50., default 1) -> composite1 (k3) + * Crop (-50.->50., default 0.) -> composite1 (k3) * Red (-50.->50., default 0.) -> colormatrix1 (values) * Green (-50.->50., default 0.) -> colormatrix1 (values) * Blue (-50.->50., default 0.) -> colormatrix1 (values) @@ -85,7 +86,7 @@ public: "<page name=\"optionstab\" _gui-text=\"Options\">\n" "<param name=\"simplifyImage\" gui-text=\"" N_("Image simplification:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10.00\">0.01</param>\n" "<param name=\"simplifyBump\" gui-text=\"" N_("Bump simplification:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10.00\">0.01</param>\n" - "<param name=\"crop\" gui-text=\"" N_("Crop:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-50.\" max=\"50.\">1</param>\n" + "<param name=\"crop\" gui-text=\"" N_("Crop:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-50.\" max=\"50.\">0</param>\n" "<_param name=\"sourceHeader\" type=\"description\" appearance=\"header\">" N_("Bump source") "</_param>\n" "<param name=\"red\" gui-text=\"" N_("Red:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-50.\" max=\"50.\">0</param>\n" "<param name=\"green\" gui-text=\"" N_("Green:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-50.\" max=\"50.\">0</param>\n" @@ -513,6 +514,221 @@ SpecularLight::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* SpecularLight filter */ +/** + \brief Custom predefined Wax Bump filter. + + Turns an image to jelly + + Filter's parameters: + Options + * Image simplification (0.01->10., default 1.5) -> blur1 (stdDeviation) + * Bump simplification (0.01->10., default 1) -> blur2 (stdDeviation) + * Crop (-10.->10., default 1.) -> colormatrix2 (4th value of the last line) + * Red (-10.->10., default 0.) -> colormatrix2 (values, substract 0.21) + * Green (-10.->10., default 0.) -> colormatrix2 (values, substract 0.72) + * Blue (-10.->10., default 0.) -> colormatrix2 (values, substract 0.07) + * Background (enum, default color) -> + * color: colormatrix1 (in="flood1") + * image: colormatrix1 (in="SourceGraphic") + * blurred image: colormatrix1 (in="blur1") + * Background opacity (0.->1., default 0) -> colormatrix1 (last value) + Lighting (specular, distant light) + * Color (guint, default -1 (RGB:255,255,255))-> lighting (lighting-color) + * Height (-50.->50., default 5.) -> lighting (surfaceScale) + * Lightness (0.->10., default 1.4) -> lighting [diffuselighting (diffuseConstant)|specularlighting (specularConstant)] + * Precision (0->50, default 35) -> lighting (specularExponent) + * Azimuth (0->360, default 225) -> lightsOptions (distantAzimuth) + * Elevation (0->180, default 60) -> lightsOptions (distantElevation) + * Lighting blend (enum, default screen) -> blend1 (mode) + * Highlight blend (enum, default screen) -> blend2 (mode) + Bump + * Trasparency type (enum [in,atop], default atop) -> composite2 (operator) + * Color (guint, default -520083713 (RGB:225,0,38)) -> flood2 (flood-color) + * Revert bump (boolean, default false) -> composite1 (false: operator="out", true operator="in") +*/ + +class WaxBump : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + WaxBump ( ) : Filter() { }; + virtual ~WaxBump ( ) { 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_("Wax Bump") "</name>\n" + "<id>org.inkscape.effect.filter.WaxBump</id>\n" + "<param name=\"tab\" type=\"notebook\">\n" + "<page name=\"optionstab\" _gui-text=\"Options\">\n" + "<param name=\"simplifyImage\" gui-text=\"" N_("Image simplification:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10.00\">1.5</param>\n" + "<param name=\"simplifyBump\" gui-text=\"" N_("Bump simplification:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10.00\">1</param>\n" + "<param name=\"crop\" gui-text=\"" N_("Crop:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">1</param>\n" + "<_param name=\"sourceHeader\" type=\"description\" appearance=\"header\">" N_("Bump source") "</_param>\n" + "<param name=\"red\" gui-text=\"" N_("Red:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0</param>\n" + "<param name=\"green\" gui-text=\"" N_("Green:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0</param>\n" + "<param name=\"blue\" gui-text=\"" N_("Blue:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0</param>\n" + "<param name=\"background\" gui-text=\"" N_("Background:") "\" type=\"enum\">\n" + "<_item value=\"flood1\">" N_("Color") "</_item>\n" + "<_item value=\"SourceGraphic\">" N_("Image") "</_item>\n" + "<_item value=\"blur1\">" N_("Blurred image") "</_item>\n" + "</param>\n" + "<param name=\"bgopacity\" gui-text=\"" N_("Background opacity:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1.\">0</param>\n" + "</page>\n" + "<page name=\"lightingtab\" _gui-text=\"Lighting\">\n" + "<param name=\"lightingColor\" gui-text=\"" N_("Color") "\" type=\"color\">-1</param>\n" + "<param name=\"height\" gui-text=\"" N_("Height:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-50.\" max=\"50.\">5</param>\n" + "<param name=\"lightness\" gui-text=\"" N_("Lightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"10.\">1.4</param>\n" + "<param name=\"precision\" gui-text=\"" N_("Precision:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"50\">35</param>\n" + "<param name=\"distantAzimuth\" gui-text=\"" N_("Azimuth:") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"360\">225</param>\n" + "<param name=\"distantElevation\" gui-text=\"" N_("Elevation:") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"180\">60</param>\n" + "<param name=\"lightingblend\" gui-text=\"" N_("Lighting blend:") "\" type=\"enum\">\n" + "<_item value=\"screen\">" N_("Screen") "</_item>\n" + "<_item value=\"normal\">" N_("Normal") "</_item>\n" + "<_item value=\"darken\">" N_("Darken") "</_item>\n" + "<_item value=\"multiply\">" N_("Multiply") "</_item>\n" + "<_item value=\"lighten\">" N_("Lighten") "</_item>\n" + "</param>\n" + "<param name=\"highlightblend\" gui-text=\"" N_("Highlight blend:") "\" type=\"enum\">\n" + "<_item value=\"screen\">" N_("Screen") "</_item>\n" + "<_item value=\"normal\">" N_("Normal") "</_item>\n" + "<_item value=\"darken\">" N_("Darken") "</_item>\n" + "<_item value=\"multiply\">" N_("Multiply") "</_item>\n" + "<_item value=\"lighten\">" N_("Lighten") "</_item>\n" + "</param>\n" + "</page>\n" + "<page name=\"colortab\" _gui-text=\"Bump\">\n" + "<param name=\"imageColor\" gui-text=\"" N_("Bump color") "\" type=\"color\">-520083713</param>\n" + "<param name=\"revert\" gui-text=\"" N_("Revert bump") "\" type=\"boolean\" >false</param>\n" + "<param name=\"transparency\" gui-text=\"" N_("Transparency type:") "\" type=\"enum\">\n" + "<_item value=\"atop\">" N_("Atop") "</_item>\n" + "<_item value=\"in\">" N_("In") "</_item>\n" + "</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_("Bumps") "\"/>\n" + "</submenu>\n" + "</effects-menu>\n" + "<menu-tip>" N_("Turns an image to jelly") "</menu-tip>\n" + "</effect>\n" + "</inkscape-extension>\n", new WaxBump()); + }; + +}; + +gchar const * +WaxBump::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream simplifyImage; + std::ostringstream simplifyBump; + std::ostringstream crop; + + std::ostringstream red; + std::ostringstream green; + std::ostringstream blue; + + std::ostringstream background; + std::ostringstream bgopacity; + + std::ostringstream height; + std::ostringstream lightness; + std::ostringstream precision; + std::ostringstream distantAzimuth; + std::ostringstream distantElevation; + + std::ostringstream lightRed; + std::ostringstream lightGreen; + std::ostringstream lightBlue; + + std::ostringstream floodRed; + std::ostringstream floodGreen; + std::ostringstream floodBlue; + std::ostringstream floodAlpha; + + std::ostringstream revert; + std::ostringstream lightingblend; + std::ostringstream highlightblend; + std::ostringstream transparency; + + simplifyImage << ext->get_param_float("simplifyImage"); + simplifyBump << ext->get_param_float("simplifyBump"); + crop << ext->get_param_float("crop"); + + red << ext->get_param_float("red") - 0.21; + green << ext->get_param_float("green") - 0.72; + blue << ext->get_param_float("blue") - 0.07; + + background << ext->get_param_enum("background"); + bgopacity << ext->get_param_float("bgopacity"); + + height << ext->get_param_float("height"); + lightness << ext->get_param_float("lightness"); + precision << ext->get_param_int("precision"); + distantAzimuth << ext->get_param_int("distantAzimuth"); + distantElevation << ext->get_param_int("distantElevation"); + + guint32 lightingColor = ext->get_param_color("lightingColor"); + lightRed << ((lightingColor >> 24) & 0xff); + lightGreen << ((lightingColor >> 16) & 0xff); + lightBlue << ((lightingColor >> 8) & 0xff); + + guint32 imageColor = ext->get_param_color("imageColor"); + floodRed << ((imageColor >> 24) & 0xff); + floodGreen << ((imageColor >> 16) & 0xff); + floodBlue << ((imageColor >> 8) & 0xff); + floodAlpha << (imageColor & 0xff) / 255.0F; + + if (ext->get_param_bool("revert")) { + revert << "in" ; + } else { + revert << "out" ; + } + + lightingblend << ext->get_param_enum("lightingblend"); + highlightblend << ext->get_param_enum("highlightblend"); + transparency << ext->get_param_enum("transparency"); + + _filter = g_strdup_printf( + "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Wax Bump\">\n" + "<feGaussianBlur in=\"SourceGraphic\" stdDeviation=\"%s\" result=\"blur1\" />\n" + "<feFlood in=\"SourceGraphic\" flood-opacity=\"1\" flood-color=\"rgb(0,255,255)\" result=\"flood1\" />\n" + "<feColorMatrix in=\"%s\" values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 %s \" result=\"colormatrix1\" />\n" + "<feColorMatrix in=\"blur1\" values=\"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 %s %s %s %s 0 \" result=\"colormatrix2\" />\n" + "<feFlood stdDeviation=\"1\" flood-color=\"rgb(%s,%s,%s)\" flood-opacity=\"%s\" result=\"flood2\" />\n" + "<feComposite in=\"flood2\" in2=\"colormatrix2\" stdDeviation=\"1\" operator=\"%s\" result=\"composite1\" />\n" + "<feGaussianBlur in=\"composite1\" stdDeviation=\"%s\" result=\"blur2\" />\n" + + "<feSpecularLighting in=\"blur2\" lighting-color=\"rgb(%s,%s,%s)\" specularConstant=\"%s\" surfaceScale=\"%s\" specularExponent=\"%s\" result=\"specular\">\n" + "<feDistantLight elevation=\"%s\" azimuth=\"%s\" />\n" + "</feSpecularLighting>\n" + "<feBlend in=\"specular\" in2=\"blur2\" specularConstant=\"1\" mode=\"%s\" blend=\"normal\" result=\"blend1\" />\n" + "<feComposite in=\"blend1\" in2=\"blur2\" k2=\"0\" operator=\"%s\" k1=\"0.5\" k3=\"0.5\" k4=\"0\" result=\"composite2\" />\n" + "<feMerge result=\"merge\">\n" + "<feMergeNode in=\"colormatrix1\" />\n" + "<feMergeNode in=\"composite2\" />\n" + "</feMerge>\n" + "<feBlend in2=\"composite2\" mode=\"%s\" blend=\"normal\" result=\"blend2\" />\n" + "<feComposite in=\"blend2\" in2=\"SourceGraphic\" operator=\"in\" result=\"composite3\" />\n" + "</filter>\n", simplifyImage.str().c_str(), background.str().c_str(), bgopacity.str().c_str(), + red.str().c_str(), green.str().c_str(), blue.str().c_str(), crop.str().c_str(), + floodRed.str().c_str(), floodGreen.str().c_str(), floodBlue.str().c_str(), floodAlpha.str().c_str(), + revert.str().c_str(), simplifyBump.str().c_str(), + lightRed.str().c_str(), lightGreen.str().c_str(), lightBlue.str().c_str(), + lightness.str().c_str(), height.str().c_str(), precision.str().c_str(), + distantElevation.str().c_str(), distantAzimuth.str().c_str(), + lightingblend.str().c_str(), transparency.str().c_str(), highlightblend.str().c_str() ); + + return _filter; + +}; /* Wax bump filter */ + }; /* namespace Filter */ }; /* namespace Internal */ }; /* namespace Extension */ diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index e19c2054d..b34c2c61f 100644 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -8,12 +8,13 @@ * Nicolas Dufour (UI) <nicoduf@yahoo.fr> * * Color filters - * Brightness + * Brilliance * Channel painting * Color shift * Colorize * Duochrome * Greyscale + * Invert * Lightness * Quadritone * Solarize @@ -35,12 +36,12 @@ namespace Internal { namespace Filter { /** - \brief Custom predefined Brightness filter. + \brief Custom predefined Brilliance filter. - Brightness filter. + Brilliance filter. Filter's parameters: - * Brightness (1.->10., default 2.) -> colorMatrix (RVB entries) + * Brilliance (1.->10., default 2.) -> colorMatrix (RVB entries) * Over-saturation (0.->10., default 0.5) -> colorMatrix (6 other entries) * Lightness (-10.->10., default 0.) -> colorMatrix (last column) * Inverted (boolean, default false) -> colorMatrix @@ -51,18 +52,18 @@ namespace Filter { Vi Vi St 0 Li 0 0 0 1 0 */ -class Brightness : public Inkscape::Extension::Internal::Filter::Filter { +class Brilliance : public Inkscape::Extension::Internal::Filter::Filter { protected: virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); public: - Brightness ( ) : Filter() { }; - virtual ~Brightness ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + Brilliance ( ) : Filter() { }; + virtual ~Brilliance ( ) { 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_("Brightness") "</name>\n" + "<name>" N_("Brilliance") "</name>\n" "<id>org.inkscape.effect.filter.Brightness</id>\n" "<param name=\"brightness\" gui-text=\"" N_("Brightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"10.00\">2</param>\n" "<param name=\"sat\" gui-text=\"" N_("Over-saturation:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.0\" max=\"10.00\">0.5</param>\n" @@ -77,12 +78,12 @@ public: "</effects-menu>\n" "<menu-tip>" N_("Brightness filter") "</menu-tip>\n" "</effect>\n" - "</inkscape-extension>\n", new Brightness()); + "</inkscape-extension>\n", new Brilliance()); }; }; gchar const * -Brightness::get_filter_text (Inkscape::Extension::Extension * ext) +Brilliance::get_filter_text (Inkscape::Extension::Extension * ext) { if (_filter != NULL) g_free((void *)_filter); @@ -101,7 +102,7 @@ Brightness::get_filter_text (Inkscape::Extension::Extension * ext) } _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=\"Brightness\">\n" + "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Brilliance\">\n" "<feColorMatrix values=\"%s %s %s 0 %s %s %s %s 0 %s %s %s %s 0 %s 0 0 0 1 0 \" />\n" "</filter>\n", brightness.str().c_str(), sat.str().c_str(), sat.str().c_str(), lightness.str().c_str(), sat.str().c_str(), brightness.str().c_str(), @@ -109,7 +110,7 @@ Brightness::get_filter_text (Inkscape::Extension::Extension * ext) sat.str().c_str(), brightness.str().c_str(), lightness.str().c_str()); return _filter; -}; /* Brightness filter */ +}; /* Brilliance filter */ /** \brief Custom predefined Channel Painting filter. @@ -608,6 +609,145 @@ Greyscale::get_filter_text (Inkscape::Extension::Extension * ext) }; /* Greyscale filter */ /** + \brief Custom predefined Invert filter. + + Manage hue, lightness and transparency inversions + + Filter's parameters: + * Invert hue (boolean, default false) -> color1 (values, true: 180, false: 0) + * Invert lightness (boolean, default false) -> color1 (values, true: 180, false: 0; XOR with Invert hue), + color2 (values: from a00 to a22, if 1, set -1 and set 1 in ax4, if -1, set 1 and set 0 in ax4) + * Invert transparency (boolean, default false) -> color2 (values: negate a30, a31 and a32, substract 1 from a33) + * Invert channels (enum, default Red and blue) -> color2 (values -for R&B: swap ax0 and ax2 in the first 3 lines) + * Light transparency (0.->1., default 0.) -> color2 (values: a33=a33-x) +*/ + +class Invert : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + Invert ( ) : Filter() { }; + virtual ~Invert ( ) { 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_("Invert") "</name>\n" + "<id>org.inkscape.effect.filter.Invert</id>\n" + "<param name=\"channels\" gui-text=\"" N_("Invert channels:") "\" type=\"enum\">\n" + "<_item value=\"0\">" N_("No invertion") "</_item>\n" + "<_item value=\"1\">" N_("Red and blue") "</_item>\n" + "<_item value=\"2\">" N_("Red and green") "</_item>\n" + "<_item value=\"3\">" N_("Green and blue") "</_item>\n" + "</param>\n" + "<param name=\"opacify\" gui-text=\"" N_("Light transparency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1\">0</param>\n" + "<param name=\"hue\" gui-text=\"" N_("Invert hue") "\" type=\"boolean\" >false</param>\n" + "<param name=\"lightness\" gui-text=\"" N_("Invert lightness") "\" type=\"boolean\" >false</param>\n" + "<param name=\"transparency\" gui-text=\"" N_("Invert transparency") "\" type=\"boolean\" >false</param>\n" + "<effect>\n" + "<object-type>all</object-type>\n" + "<effects-menu>\n" + "<submenu name=\"" N_("Filters") "\">\n" + "<submenu name=\"" N_("Color") "\"/>\n" + "</submenu>\n" + "</effects-menu>\n" + "<menu-tip>" N_("Manage hue, lightness and transparency inversions") "</menu-tip>\n" + "</effect>\n" + "</inkscape-extension>\n", new Invert()); + }; + +}; + +gchar const * +Invert::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream line1; + std::ostringstream line2; + std::ostringstream line3; + + std::ostringstream col5; + std::ostringstream transparency; + std::ostringstream hue; + + if (ext->get_param_bool("hue") xor ext->get_param_bool("lightness")) { + hue << "<feColorMatrix type=\"hueRotate\" values=\"180\" result=\"color1\" />\n"; + } else { + hue << ""; + } + + if (ext->get_param_bool("transparency")) { + transparency << "0.21 0.72 0.07 " << 1 - ext->get_param_float("opacify"); + } else { + transparency << "-0.21 -0.72 -0.07 " << 2 - ext->get_param_float("opacify"); + } + + if (ext->get_param_bool("lightness")) { + switch (atoi(ext->get_param_enum("channels"))) { + case 1: + line1 << "0 0 -1"; + line2 << "0 -1 0"; + line3 << "-1 0 0"; + break; + case 2: + line1 << "0 -1 0"; + line2 << "-1 0 0"; + line3 << "0 0 -1"; + break; + case 3: + line1 << "-1 0 0"; + line2 << "0 0 -1"; + line3 << "0 -1 0"; + break; + default: + line1 << "-1 0 0"; + line2 << "0 -1 0"; + line3 << "0 0 -1"; + break; + } + col5 << "1"; + } else { + switch (atoi(ext->get_param_enum("channels"))) { + case 1: + line1 << "0 0 1"; + line2 << "0 1 0"; + line3 << "1 0 0"; + break; + case 2: + line1 << "0 1 0"; + line2 << "1 0 0"; + line3 << "0 0 1"; + break; + case 3: + line1 << "1 0 0"; + line2 << "0 0 1"; + line3 << "0 1 0"; + break; + default: + line1 << "1 0 0"; + line2 << "0 1 0"; + line3 << "0 0 1"; + break; + } + col5 << "0"; + } + + _filter = g_strdup_printf( + "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Invert\">\n" + "%s" + "<feColorMatrix values=\"%s 0 %s %s 0 %s %s 0 %s %s 0 \" result=\"color2\" />\n" + "</filter>\n", hue.str().c_str(), + line1.str().c_str(), col5.str().c_str(), + line2.str().c_str(), col5.str().c_str(), + line3.str().c_str(), col5.str().c_str(), + transparency.str().c_str() ); + + return _filter; +}; /* Invert filter */ + +/** \brief Custom predefined Lightness filter. Modify lights and shadows separately. diff --git a/src/extension/internal/filter/distort.h b/src/extension/internal/filter/distort.h index 7157722d7..3972029ae 100644 --- a/src/extension/internal/filter/distort.h +++ b/src/extension/internal/filter/distort.h @@ -8,6 +8,7 @@ * Nicolas Dufour (UI) <nicoduf@yahoo.fr> * * Distort filters + * Felt Feather * Roughen * * Released under GNU GPL, read the file 'COPYING' for more information @@ -26,14 +27,147 @@ namespace Internal { namespace Filter { /** + \brief Custom predefined FeltFeather filter. + + Blur and displace edges of shapes and pictures + + Filter's parameters: + * Type (enum, default "In") -> + in = map (in="composite3") + out = map (in="blur") + * Horizontal blur (0.01->30., default 15) -> blur (stdDeviation) + * Vertical blur (0.01->30., default 15) -> blur (stdDeviation) + * Dilatation (n-1th value, 0.->100., default 1) -> colormatrix (matrix) + * Erosion (nth value, 0.->100., default 0) -> colormatrix (matrix) + * Stroke (enum, default "Normal") -> + Normal = composite4 (operator="atop") + Wide = composite4 (operator="over") + Narrow = composite4 (operator="in") + No fill = composite4 (operator="xor") + + * Roughness (group) + * Turbulence type (enum, default fractalNoise else turbulence) -> turbulence (type) + * Horizontal frequency (0.001->1., default 0.05) -> turbulence (baseFrequency [/1000]) + * Vertical frequency (0.001->1., default 0.05) -> turbulence (baseFrequency [/1000]) + * Complexity (1->5, default 3) -> turbulence (numOctaves) + * Variation (0->100, default 0) -> turbulence (seed) +*/ + +class FeltFeather : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + FeltFeather ( ) : Filter() { }; + virtual ~FeltFeather ( ) { 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_("Felt Feather") "</name>\n" + "<id>org.inkscape.effect.filter.FeltFeather</id>\n" + "<param name=\"type\" gui-text=\"" N_("Type:") "\" type=\"enum\">\n" + "<_item value=\"in\">" N_("In") "</_item>\n" + "<_item value=\"out\">" N_("Out") "</_item>\n" + "</param>\n" + "<param name=\"hblur\" gui-text=\"" N_("Horizontal blur:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"30.00\">15</param>\n" + "<param name=\"vblur\" gui-text=\"" N_("Vertical blur:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"30.00\">15</param>\n" + "<param name=\"dilat\" gui-text=\"" N_("Dilatation:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"100\">1</param>\n" + "<param name=\"erosion\" gui-text=\"" N_("Erosion:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"100\">0</param>\n" + "<param name=\"stroke\" gui-text=\"" N_("Stroke:") "\" type=\"enum\">\n" + "<_item value=\"atop\">" N_("Normal") "</_item>\n" + "<_item value=\"over\">" N_("Wide") "</_item>\n" + "<_item value=\"in\">" N_("Narrow") "</_item>\n" + "<_item value=\"xor\">" N_("No fill") "</_item>\n" + "</param>\n" + "<param name=\"turbulence\" indent=\"1\" gui-text=\"" N_("Turbulence:") "\" type=\"enum\">\n" + "<_item value=\"fractalNoise\">Fractal noise</_item>\n" + "<_item value=\"turbulence\">Turbulence</_item>\n" + "</param>\n" + "<param name=\"hfreq\" gui-text=\"" N_("Horizontal frequency:") "\" type=\"float\" appearance=\"full\" precision=\"3\" min=\"0.001\" max=\"1.\">0.05</param>\n" + "<param name=\"vfreq\" gui-text=\"" N_("Vertical frequency:") "\" type=\"float\" appearance=\"full\" precision=\"3\" min=\"0.001\" max=\"1.\">0.05</param>\n" + "<param name=\"complexity\" gui-text=\"" N_("Complexity:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"5\">3</param>\n" + "<param name=\"variation\" gui-text=\"" N_("Variation:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"100\">0</param>\n" + "<effect>\n" + "<object-type>all</object-type>\n" + "<effects-menu>\n" + "<submenu name=\"" N_("Filters") "\">\n" + "<submenu name=\"" N_("Distort") "\"/>\n" + "</submenu>\n" + "</effects-menu>\n" + "<menu-tip>" N_("Blur and displace edges of shapes and pictures") "</menu-tip>\n" + "</effect>\n" + "</inkscape-extension>\n", new FeltFeather()); + }; + +}; + +gchar const * +FeltFeather::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + + std::ostringstream hblur; + std::ostringstream vblur; + std::ostringstream dilat; + std::ostringstream erosion; + + std::ostringstream turbulence; + std::ostringstream hfreq; + std::ostringstream vfreq; + std::ostringstream complexity; + std::ostringstream variation; + + std::ostringstream map; + std::ostringstream stroke; + + hblur << ext->get_param_float("hblur"); + vblur << ext->get_param_float("vblur"); + dilat << ext->get_param_float("dilat"); + erosion << -ext->get_param_float("erosion"); + + turbulence << ext->get_param_enum("turbulence"); + hfreq << ext->get_param_float("hfreq"); + vfreq << ext->get_param_float("vfreq"); + complexity << ext->get_param_int("complexity"); + variation << ext->get_param_int("variation"); + + stroke << ext->get_param_enum("stroke"); + + const gchar *maptype = ext->get_param_enum("type"); + if (g_ascii_strcasecmp("in", maptype) == 0) { + map << "composite3"; + } else { + map << "blur"; + } + + _filter = g_strdup_printf( + "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" x=\"-0.3\" width=\"1.6\" y=\"-0.3\" height=\"1.6\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Felt Feather\">\n" + "<feGaussianBlur stdDeviation=\"%s %s\" result=\"blur\" />\n" + "<feComposite in=\"SourceGraphic\" in2=\"blur\" operator=\"atop\" result=\"composite1\" />\n" + "<feComposite in2=\"composite1\" operator=\"in\" result=\"composite2\" />\n" + "<feComposite in2=\"composite2\" operator=\"in\" result=\"composite3\" />\n" + "<feTurbulence type=\"%s\" numOctaves=\"%s\" seed=\"%s\" baseFrequency=\"%s %s\" result=\"turbulence\" />\n" + "<feDisplacementMap in=\"%s\" in2=\"turbulence\" xChannelSelector=\"R\" scale=\"30\" yChannelSelector=\"G\" result=\"map\" />\n" + "<feColorMatrix 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=\"composite3\" in2=\"colormatrix\" operator=\"%s\" result=\"composite4\" />\n" + "</filter>\n", hblur.str().c_str(), vblur.str().c_str(), + turbulence.str().c_str(), complexity.str().c_str(), variation.str().c_str(), hfreq.str().c_str(), vfreq.str().c_str(), + map.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), stroke.str().c_str() ); + + return _filter; +}; /* Felt feather filter */ + +/** \brief Custom predefined Roughen filter. Small-scale roughening to edges and content Filter's parameters: * Turbulence type (enum, default fractalNoise else turbulence) -> turbulence (type) - * Horizontal frequency (*1000) (0.01->10000., default 13) -> turbulence (baseFrequency [/1000]) - * Vertical frequency (*1000) (0.01->10000., default 13) -> turbulence (baseFrequency [/1000]) + * Horizontal frequency (0.01->10., default 0.013) -> turbulence (baseFrequency) + * Vertical frequency (0.01->10., default 0.013) -> turbulence (baseFrequency) * Complexity (1->5, default 5) -> turbulence (numOctaves) * Variation (1->360, default 1) -> turbulence (seed) * Intensity (0.0->50., default 6.6) -> displacement (scale) @@ -56,8 +190,8 @@ public: "<_item value=\"fractalNoise\">Fractal noise</_item>\n" "<_item value=\"turbulence\">Turbulence</_item>\n" "</param>\n" - "<param name=\"hfreq\" gui-text=\"" N_("Horizontal frequency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10000.00\">13</param>\n" - "<param name=\"vfreq\" gui-text=\"" N_("Vertical frequency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10000.00\">13</param>\n" + "<param name=\"hfreq\" gui-text=\"" N_("Horizontal frequency:") "\" type=\"float\" appearance=\"full\" precision=\"3\" min=\"0.001\" max=\"10.00\">0.013</param>\n" + "<param name=\"vfreq\" gui-text=\"" N_("Vertical frequency:") "\" type=\"float\" appearance=\"full\" precision=\"3\" min=\"0.001\" max=\"10.00\">0.013</param>\n" "<param name=\"complexity\" gui-text=\"" N_("Complexity:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"5\">5</param>\n" "<param name=\"variation\" gui-text=\"" N_("Variation:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"360\">0</param>\n" "<param name=\"intensity\" gui-text=\"" N_("Intensity:") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"50\">6.6</param>\n" @@ -88,8 +222,8 @@ Roughen::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream intensity; type << ext->get_param_enum("type"); - hfreq << (ext->get_param_float("hfreq") / 1000); - vfreq << (ext->get_param_float("vfreq") / 1000); + hfreq << ext->get_param_float("hfreq"); + vfreq << ext->get_param_float("vfreq"); complexity << ext->get_param_int("complexity"); variation << ext->get_param_int("variation"); intensity << ext->get_param_float("intensity"); diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp index 5b3280656..dcd68b75a 100755 --- a/src/extension/internal/filter/filter-all.cpp +++ b/src/extension/internal/filter/filter-all.cpp @@ -45,20 +45,23 @@ Filter::filters_all (void ) DiffuseLight::init(); MatteJelly::init(); SpecularLight::init(); + WaxBump::init(); // Color - Brightness::init(); + Brilliance::init(); ChannelPaint::init(); ColorShift::init(); Colorize::init(); Duochrome::init(); Greyscale::init(); + Invert::init(); Lightness::init(); Quadritone::init(); Solarize::init(); Tritone::init(); // Distort + FeltFeather::init(); Roughen::init(); // Image effect @@ -70,6 +73,7 @@ Filter::filters_all (void ) Drawing::init(); Electrize::init(); NeonDraw::init(); + //PointEngraving::init(); Posterize::init(); PosterizeBasic::init(); @@ -86,6 +90,9 @@ Filter::filters_all (void ) // Shadows and glows ColorizableDropShadow::init(); + // Textures + // InkBlot::init(); + // Fill and transparency ChannelTransparency::init(); Silhouette::init(); diff --git a/src/extension/internal/filter/paint.h b/src/extension/internal/filter/paint.h index c2eb0c0ae..a3077d1c4 100644 --- a/src/extension/internal/filter/paint.h +++ b/src/extension/internal/filter/paint.h @@ -628,12 +628,13 @@ NeonDraw::get_filter_text (Inkscape::Extension::Extension * ext) lightness << ext->get_param_float("lightness"); const gchar *typestr = ext->get_param_enum("type"); - if (ext->get_param_bool("dark")) + if (ext->get_param_bool("dark")) { dark << "component2"; - else if ((g_ascii_strcasecmp("table", typestr) == 0)) + } else if ((g_ascii_strcasecmp("table", typestr) == 0)) { dark << "blur2"; - else + } else { dark << "component1"; + } _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=\"Neon Draw\">\n" |
