diff options
| author | Nicolas Dufour <nicoduf@yahoo.fr> | 2011-08-06 20:11:25 +0000 |
|---|---|---|
| committer | JazzyNico <nicoduf@yahoo.fr> | 2011-08-06 20:11:25 +0000 |
| commit | 929f61c316838dd4a8823399df845aa699b9d4e9 (patch) | |
| tree | 7184aa11d557411379e09bb2dc8d4962c23aa82f /src | |
| parent | Extensions. New "indent" attribute to add an indent level to extension elements. (diff) | |
| download | inkscape-929f61c316838dd4a8823399df845aa699b9d4e9.tar.gz inkscape-929f61c316838dd4a8823399df845aa699b9d4e9.zip | |
Filters. Global custom predefined filters reorganization.
(bzr r10530)
Diffstat (limited to 'src')
| -rwxr-xr-x | src/extension/internal/filter/abc.h | 819 | ||||
| -rw-r--r-- | src/extension/internal/filter/blurs.h | 133 | ||||
| -rw-r--r-- | src/extension/internal/filter/bumps.h | 256 | ||||
| -rw-r--r--[-rwxr-xr-x] | src/extension/internal/filter/color.h | 126 | ||||
| -rw-r--r-- | src/extension/internal/filter/distort.h | 112 | ||||
| -rw-r--r-- | src/extension/internal/filter/drop-shadow.h | 150 | ||||
| -rwxr-xr-x | src/extension/internal/filter/filter-all.cpp | 64 | ||||
| -rw-r--r-- | src/extension/internal/filter/image.h | 6 | ||||
| -rw-r--r-- | src/extension/internal/filter/morphology.h | 98 | ||||
| -rw-r--r-- | src/extension/internal/filter/overlays.h | 147 | ||||
| -rw-r--r--[-rwxr-xr-x] | src/extension/internal/filter/paint.h (renamed from src/extension/internal/filter/experimental.h) | 48 | ||||
| -rw-r--r-- | src/extension/internal/filter/protrusions.h (renamed from src/extension/internal/filter/snow.h) | 29 | ||||
| -rw-r--r-- | src/extension/internal/filter/shadows.h | 8 | ||||
| -rw-r--r-- | src/extension/internal/filter/transparency.h | 192 |
14 files changed, 1056 insertions, 1132 deletions
diff --git a/src/extension/internal/filter/abc.h b/src/extension/internal/filter/abc.h deleted file mode 100755 index 832fb90c2..000000000 --- a/src/extension/internal/filter/abc.h +++ /dev/null @@ -1,819 +0,0 @@ -#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_ABC_H__ -#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_ABC_H__ -/* Change the 'ABC' above to be your file name */ - -/* - * Copyright (C) 2011 Authors: - * Ivan Louette (filters) - * Nicolas Dufour (UI) <nicoduf@yahoo.fr> - * - * Basic filters - * Clean edges - * Color shift - * Diffuse light - * Feather - * Matte jelly - * Noise fill - * Outline - * Roughen - * Silhouette - * Specular light - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ -/* ^^^ Change the copyright to be you and your e-mail address ^^^ */ - -#include "filter.h" - -#include "extension/internal/clear-n_.h" -#include "extension/system.h" -#include "extension/extension.h" - -namespace Inkscape { -namespace Extension { -namespace Internal { -namespace Filter { - -/** - \brief Custom predefined Clean edges filter. - - Removes or decreases glows and jaggeries around objects edges after applying some filters - - Filter's parameters: - * Strength (0.01->2., default 0.4) -> blur (stdDeviation) -*/ - -class CleanEdges : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - CleanEdges ( ) : Filter() { }; - virtual ~CleanEdges ( ) { 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_("Clean edges, custom (ABCs)") "</name>\n" - "<id>org.inkscape.effect.filter.CleanEdges</id>\n" - "<param name=\"blur\" gui-text=\"" N_("Strength:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"2.00\">0.4</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_("Removes or decreases glows and jaggeries around objects edges after applying some filters") "</menu-tip>\n" - "</effect>\n" - "</inkscape-extension>\n", new CleanEdges()); - }; - -}; - -gchar const * -CleanEdges::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream blur; - - blur << ext->get_param_float("blur"); - - _filter = g_strdup_printf( - "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Clean edges, custom\">\n" - "<feGaussianBlur stdDeviation=\"%s\" result=\"blur\" />\n" - "<feComposite in=\"SourceGraphic\" in2=\"blur\" operator=\"in\" result=\"composite1\" />\n" - "<feComposite in=\"composite1\" in2=\"composite1\" k2=\"1\" operator=\"in\" result=\"composite2\" />\n" - "</filter>\n", blur.str().c_str()); - - return _filter; -}; /* CleanEdges filter */ - - -/** - \brief Custom predefined Color shift filter. - - Rotate and desaturate hue - - Filter's parameters: - * Shift (0->360, default 330) -> color1 (values) - * Saturation (0.->1., default 0.6) -> color2 (values) -*/ - -class ColorShift : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - ColorShift ( ) : Filter() { }; - virtual ~ColorShift ( ) { 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_("Color shift, custom (ABCs)") "</name>\n" - "<id>org.inkscape.effect.filter.ColorShift</id>\n" - "<param name=\"shift\" gui-text=\"" N_("Shift (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">330</param>\n" - "<param name=\"sat\" gui-text=\"" N_("Saturation:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1\">0.6</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_("Rotate and desaturate hue") "</menu-tip>\n" - "</effect>\n" - "</inkscape-extension>\n", new ColorShift()); - }; - -}; - -gchar const * -ColorShift::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream shift; - std::ostringstream sat; - - shift << ext->get_param_int("shift"); - sat << ext->get_param_float("sat"); - - _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=\"Color shift, custom\">\n" - "<feColorMatrix type=\"hueRotate\" values=\"%s\" result=\"color1\" />\n" - "<feColorMatrix type=\"saturate\" values=\"%s\" result=\"color2\" />\n" - "</filter>\n", shift.str().c_str(), sat.str().c_str()); - - return _filter; -}; /* ColorShift filter */ - -/** - \brief Custom predefined Diffuse light filter. - - Basic diffuse bevel to use for building textures - - Filter's parameters: - * Smoothness (0.->10., default 6.) -> blur (stdDeviation) - * Elevation (0->360, default 25) -> feDistantLight (elevation) - * Azimuth (0->360, default 235) -> feDistantLight (azimuth) - * Lighting color (guint, default -1 [white]) -> diffuse (lighting-color) -*/ - -class DiffuseLight : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - DiffuseLight ( ) : Filter() { }; - virtual ~DiffuseLight ( ) { 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_("Diffuse light, custom (ABCs)") "</name>\n" - "<id>org.inkscape.effect.filter.DiffuseLight</id>\n" - "<param name=\"smooth\" gui-text=\"" N_("Smoothness:") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"10\">6</param>\n" - "<param name=\"elevation\" gui-text=\"" N_("Elevation (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">25</param>\n" - "<param name=\"azimuth\" gui-text=\"" N_("Azimuth (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">235</param>\n" - "<param name=\"color\" gui-text=\"" N_("Lighting color") "\" type=\"color\">-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_("Basic diffuse bevel to use for building textures") "</menu-tip>\n" - "</effect>\n" - "</inkscape-extension>\n", new DiffuseLight()); - }; - -}; - -gchar const * -DiffuseLight::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream smooth; - std::ostringstream elevation; - std::ostringstream azimuth; - std::ostringstream r; - std::ostringstream g; - std::ostringstream b; - std::ostringstream a; - - smooth << ext->get_param_float("smooth"); - elevation << ext->get_param_int("elevation"); - azimuth << ext->get_param_int("azimuth"); - guint32 color = ext->get_param_color("color"); - - r << ((color >> 24) & 0xff); - g << ((color >> 16) & 0xff); - b << ((color >> 8) & 0xff); - a << (color & 0xff) / 255.0F; - - _filter = g_strdup_printf( - "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Diffuse light, custom\">\n" - "<feGaussianBlur in=\"SourceGraphic\" stdDeviation=\"%s\" result=\"blur\" />\n" - "<feDiffuseLighting diffuseConstant=\"1\" surfaceScale=\"10\" lighting-color=\"rgb(%s,%s,%s)\" result=\"diffuse\">\n" - "<feDistantLight elevation=\"%s\" azimuth=\"%s\" />\n" - "</feDiffuseLighting>\n" - "<feComposite in=\"diffuse\" in2=\"diffuse\" operator=\"arithmetic\" k1=\"1\" result=\"composite1\" />\n" - "<feComposite in=\"composite1\" in2=\"SourceGraphic\" k1=\"%s\" operator=\"arithmetic\" k3=\"1\" result=\"composite2\" />\n" - "</filter>\n", smooth.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), elevation.str().c_str(), azimuth.str().c_str(), a.str().c_str()); - - return _filter; -}; /* DiffuseLight filter */ - -/** - \brief Custom predefined Feather filter. - - Blurred mask on the edge without altering the contents - - Filter's parameters: - * Strength (0.01->100., default 5) -> blur (stdDeviation) -*/ - -class Feather : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - Feather ( ) : Filter() { }; - virtual ~Feather ( ) { 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_("Feather, custom (ABCs)") "</name>\n" - "<id>org.inkscape.effect.filter.Feather</id>\n" - "<param name=\"blur\" gui-text=\"" N_("Strength:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.00\">5</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_("Blurred mask on the edge without altering the contents") "</menu-tip>\n" - "</effect>\n" - "</inkscape-extension>\n", new Feather()); - }; - -}; - -gchar const * -Feather::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream blur; - - blur << ext->get_param_float("blur"); - - _filter = g_strdup_printf( - "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Black outline, custom\">\n" - "<feGaussianBlur stdDeviation=\"%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" - "</filter>\n", blur.str().c_str()); - - return _filter; -}; /* Feather filter */ - -/** - \brief Custom predefined Matte jelly filter. - - Bulging, matte jelly covering - - Filter's parameters: - * Smoothness (0.0->10., default 7.) -> blur (stdDeviation) - * Brightness (0.0->5., default .9) -> specular (specularConstant) - * Elevation (0->360, default 60) -> feDistantLight (elevation) - * Azimuth (0->360, default 225) -> feDistantLight (azimuth) - * Lighting color (guint, default -1 [white]) -> specular (lighting-color) -*/ - -class MatteJelly : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - MatteJelly ( ) : Filter() { }; - virtual ~MatteJelly ( ) { 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_("Matte jelly, custom (ABCs)") "</name>\n" - "<id>org.inkscape.effect.filter.MatteJelly</id>\n" - "<param name=\"smooth\" gui-text=\"" N_("Smoothness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"10.00\">7</param>\n" - "<param name=\"bright\" gui-text=\"" N_("Brightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"5.00\">0.9</param>\n" - "<param name=\"elevation\" gui-text=\"" N_("Elevation (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">60</param>\n" - "<param name=\"azimuth\" gui-text=\"" N_("Azimuth (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">225</param>\n" - "<param name=\"color\" gui-text=\"" N_("Lighting color") "\" type=\"color\">-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_("Bulging, matte jelly covering") "</menu-tip>\n" - "</effect>\n" - "</inkscape-extension>\n", new MatteJelly()); - }; - -}; - -gchar const * -MatteJelly::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream smooth; - std::ostringstream bright; - std::ostringstream elevation; - std::ostringstream azimuth; - std::ostringstream r; - std::ostringstream g; - std::ostringstream b; - std::ostringstream a; - - smooth << ext->get_param_float("smooth"); - bright << ext->get_param_float("bright"); - elevation << ext->get_param_int("elevation"); - azimuth << ext->get_param_int("azimuth"); - guint32 color = ext->get_param_color("color"); - - r << ((color >> 24) & 0xff); - g << ((color >> 16) & 0xff); - b << ((color >> 8) & 0xff); - a << (color & 0xff) / 255.0F; - - _filter = g_strdup_printf( - "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Matte jelly, custom\">\n" - "<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0.85 0\" result=\"color\" in=\"SourceGraphic\" />\n" - "<feGaussianBlur in=\"SourceAlpha\" stdDeviation=\"%s\" result=\"blur\" />\n" - "<feSpecularLighting in=\"blur\" specularExponent=\"25\" specularConstant=\"%s\" surfaceScale=\"5\" lighting-color=\"rgb(%s,%s,%s)\" result=\"specular\">\n" - "<feDistantLight elevation=\"%s\" azimuth=\"%s\" />\n" - "</feSpecularLighting>\n" - "<feComposite in=\"specular\" in2=\"SourceGraphic\" k3=\"1\" k2=\"%s\" operator=\"arithmetic\" result=\"composite1\" />\n" - "<feComposite in=\"composite1\" in2=\"color\" operator=\"atop\" result=\"composite2\" />\n" - "</filter>\n", smooth.str().c_str(), bright.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), elevation.str().c_str(), azimuth.str().c_str(), a.str().c_str()); - - return _filter; -}; /* MatteJelly filter */ - -/** - \brief Custom predefined Noise fill filter. - - Basic noise fill and transparency texture - - Filter's parameters: - * Turbulence type (enum, default fractalNoise else turbulence) -> turbulence (type) - * Horizontal frequency (*1000) (0.01->10000., default 20) -> turbulence (baseFrequency [/1000]) - * Vertical frequency (*1000) (0.01->10000., default 40) -> turbulence (baseFrequency [/1000]) - * Complexity (1->5, default 5) -> turbulence (numOctaves) - * Variation (1->360, default 1) -> turbulence (seed) - * Dilatation (1.->50., default 3) -> color (n-1th value) - * Erosion (0.->50., default 1) -> color (nth value 0->-50) - * Color (guint, default 148,115,39,255) -> flood (flood-color, flood-opacity) - * Inverted (boolean, default false) -> composite1 (operator, true="in", false="out") -*/ - -class NoiseFill : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - NoiseFill ( ) : Filter() { }; - virtual ~NoiseFill ( ) { 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_("Noise fill, custom (ABCs)") "</name>\n" - "<id>org.inkscape.effect.filter.NoiseFill</id>\n" - "<param name=\"tab\" type=\"notebook\">\n" - "<page name=\"optionstab\" _gui-text=\"Options\">\n" - "<param name=\"type\" gui-text=\"" N_("Turbulence type:") "\" 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=\"2\" min=\"0.01\" max=\"10000.00\">20</param>\n" - "<param name=\"vfreq\" gui-text=\"" N_("Vertical frequency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10000.00\">40</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=\"dilat\" gui-text=\"" N_("Dilatation:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"50\">3</param>\n" - "<param name=\"erosion\" gui-text=\"" N_("Erosion:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"50\">1</param>\n" - "<param name=\"inverted\" gui-text=\"" N_("Inverted") "\" type=\"boolean\" >false</param>\n" - "</page>\n" - "<page name=\"co11tab\" _gui-text=\"Noise color\">\n" - "<param name=\"color\" gui-text=\"" N_("Color") "\" type=\"color\">354957823</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_("Basic noise fill and transparency texture") "</menu-tip>\n" - "</effect>\n" - "</inkscape-extension>\n", new NoiseFill()); - }; - -}; - -gchar const * -NoiseFill::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream type; - std::ostringstream hfreq; - std::ostringstream vfreq; - std::ostringstream complexity; - std::ostringstream variation; - std::ostringstream dilat; - std::ostringstream erosion; - std::ostringstream r; - std::ostringstream g; - std::ostringstream b; - std::ostringstream a; - std::ostringstream inverted; - - type << ext->get_param_enum("type"); - hfreq << (ext->get_param_float("hfreq") / 1000); - vfreq << (ext->get_param_float("vfreq") / 1000); - complexity << ext->get_param_int("complexity"); - variation << ext->get_param_int("variation"); - dilat << ext->get_param_float("dilat"); - erosion << (- ext->get_param_float("erosion")); - guint32 color = ext->get_param_color("color"); - r << ((color >> 24) & 0xff); - g << ((color >> 16) & 0xff); - b << ((color >> 8) & 0xff); - a << (color & 0xff) / 255.0F; - if (ext->get_param_bool("inverted")) - inverted << "out"; - else - inverted << "in"; - - _filter = g_strdup_printf( - "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Noise fill, custom\">\n" - "<feTurbulence type=\"%s\" baseFrequency=\"%s %s\" numOctaves=\"%s\" seed=\"%s\" result=\"turbulence\"/>\n" - "<feComposite in=\"SourceGraphic\" in2=\"turbulence\" operator=\"%s\" result=\"composite1\" />\n" - "<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 %s %s \" result=\"color\" />\n" - "<feFlood in=\"color\" flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood\" />\n" - "<feMerge result=\"merge\">\n" - "<feMergeNode in=\"flood\" />\n" - "<feMergeNode in=\"color\" />\n" - "</feMerge>\n" - "<feComposite in2=\"SourceGraphic\" operator=\"in\" result=\"composite2\" />\n" - "</filter>\n", type.str().c_str(), hfreq.str().c_str(), vfreq.str().c_str(), complexity.str().c_str(), variation.str().c_str(), inverted.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str()); - - return _filter; -}; /* NoiseFill filter */ - -/** - \brief Custom predefined Outline filter. - - Adds a colorizable outline - - Filter's parameters: - * Width (0.01->50., default 5) -> blur1 (stdDeviation) - * Melt (0.01->50., default 2) -> blur2 (stdDeviation) - * Dilatation (1.->50., default 8) -> color2 (n-1th value) - * Erosion (0.->50., default 5) -> color2 (nth value 0->-50) - * Color (guint, default 156,102,102,255) -> flood (flood-color, flood-opacity) - * Blend (enum, default Normal) -> blend (mode) -*/ - -class Outline : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - Outline ( ) : Filter() { }; - virtual ~Outline ( ) { 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_("Outline, custom (ABCs)") "</name>\n" - "<id>org.inkscape.effect.filter.Outline</id>\n" - "<param name=\"tab\" type=\"notebook\">\n" - "<page name=\"optionstab\" _gui-text=\"Options\">\n" - "<param name=\"width\" gui-text=\"" N_("Width:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"50.00\">5</param>\n" - "<param name=\"melt\" gui-text=\"" N_("Melt:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"50.00\">2</param>\n" - "<param name=\"dilat\" gui-text=\"" N_("Dilatation:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"50\">8</param>\n" - "<param name=\"erosion\" gui-text=\"" N_("Erosion:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"50\">5</param>\n" - "</page>\n" - "<page name=\"co11tab\" _gui-text=\"Color\">\n" - "<param name=\"color\" gui-text=\"" N_("Color") "\" type=\"color\">1029214207</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_("Adds a colorizable outline") "</menu-tip>\n" - "</effect>\n" - "</inkscape-extension>\n", new Outline()); - }; - -}; - -gchar const * -Outline::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream width; - std::ostringstream melt; - std::ostringstream dilat; - std::ostringstream erosion; - std::ostringstream r; - std::ostringstream g; - std::ostringstream b; - std::ostringstream a; - std::ostringstream blend; - - width << ext->get_param_float("width"); - melt << ext->get_param_float("melt"); - dilat << ext->get_param_float("dilat"); - erosion << (- ext->get_param_float("erosion")); - guint32 color = ext->get_param_color("color"); - r << ((color >> 24) & 0xff); - g << ((color >> 16) & 0xff); - b << ((color >> 8) & 0xff); - a << (color & 0xff) / 255.0F; - - _filter = g_strdup_printf( - "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1.3\" width=\"1.3\" y=\"-0.15\" x=\"-0.15\" inkscape:label=\"Outline, custom\">\n" - "<feGaussianBlur in=\"SourceAlpha\" stdDeviation=\"%s\" result=\"blur1\" />\n" - "<feColorMatrix result=\"color1\" values=\"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 200 -1 \" />\n" - "<feGaussianBlur in=\"color1\" 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 %s \" result=\"color2\" />\n" - "<feFlood in=\"color2\" result=\"flood\" flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" />\n" - "<feComposite in=\"flood\" in2=\"color2\" operator=\"in\" result=\"composite\" />\n" - "<feBlend in=\"SourceGraphic\" in2=\"composite\" mode=\"normal\" blend=\"normal\" />\n" - "</filter>\n", width.str().c_str(), melt.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str()); - - return _filter; -}; /* Outline 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]) - * Complexity (1->5, default 5) -> turbulence (numOctaves) - * Variation (1->360, default 1) -> turbulence (seed) - * Intensity (0.0->50., default 6.6) -> displacement (scale) -*/ - -class Roughen : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - Roughen ( ) : Filter() { }; - virtual ~Roughen ( ) { 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_("Roughen, custom (ABCs)") "</name>\n" - "<id>org.inkscape.effect.filter.Roughen</id>\n" - "<param name=\"type\" gui-text=\"" N_("Turbulence type:") "\" 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=\"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=\"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" - "<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_("Small-scale roughening to edges and content") "</menu-tip>\n" - "</effect>\n" - "</inkscape-extension>\n", new Roughen()); - }; - -}; - -gchar const * -Roughen::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream type; - std::ostringstream hfreq; - std::ostringstream vfreq; - std::ostringstream complexity; - std::ostringstream variation; - std::ostringstream intensity; - - type << ext->get_param_enum("type"); - hfreq << (ext->get_param_float("hfreq") / 1000); - vfreq << (ext->get_param_float("vfreq") / 1000); - complexity << ext->get_param_int("complexity"); - variation << ext->get_param_int("variation"); - intensity << ext->get_param_float("intensity"); - - _filter = g_strdup_printf( - "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Roughen, custom\">\n" - "<feTurbulence type=\"%s\" numOctaves=\"%s\" seed=\"%s\" baseFrequency=\"%s %s\" result=\"turbulence\" />\n" - "<feDisplacementMap in=\"SourceGraphic\" in2=\"turbulence\" scale=\"%s\" yChannelSelector=\"G\" xChannelSelector=\"R\" />\n" - "</filter>\n", type.str().c_str(), complexity.str().c_str(), variation.str().c_str(), hfreq.str().c_str(), vfreq.str().c_str(), intensity.str().c_str()); - - return _filter; -}; /* Roughen filter */ - -/** - \brief Custom predefined Silhouette filter. - - Repaint anything visible monochrome - - Filter's parameters: - * Blur (0.01->50., default 0.01) -> blur (stdDeviation) - * Cutout (boolean, default False) -> composite (false=in, true=out) - * Color (guint, default 0,0,0,255) -> flood (flood-color, flood-opacity) -*/ - -class Silhouette : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - Silhouette ( ) : Filter() { }; - virtual ~Silhouette ( ) { 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_("Silhouette, custom (ABCs)") "</name>\n" - "<id>org.inkscape.effect.filter.Silhouette</id>\n" - "<param name=\"blur\" gui-text=\"" N_("Blur:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"50.00\">0.01</param>\n" - "<param name=\"cutout\" gui-text=\"" N_("Cutout") "\" type=\"boolean\">false</param>\n" - "<param name=\"color\" gui-text=\"" N_("Color") "\" type=\"color\">255</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_("Repaint anything visible monochrome") "</menu-tip>\n" - "</effect>\n" - "</inkscape-extension>\n", new Silhouette()); - }; - -}; - -gchar const * -Silhouette::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream a; - std::ostringstream r; - std::ostringstream g; - std::ostringstream b; - std::ostringstream cutout; - std::ostringstream blur; - - guint32 color = ext->get_param_color("color"); - r << ((color >> 24) & 0xff); - g << ((color >> 16) & 0xff); - b << ((color >> 8) & 0xff); - a << (color & 0xff) / 255.0F; - if (ext->get_param_bool("cutout")) - cutout << "out"; - else - cutout << "in"; - blur << ext->get_param_float("blur"); - - _filter = g_strdup_printf( - "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Silhouette, custom\">\n" - "<feFlood in=\"SourceGraphic\" flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood\" />\n" - "<feComposite in=\"flood\" in2=\"SourceGraphic\" operator=\"%s\" result=\"composite\" />\n" - "<feGaussianBlur stdDeviation=\"%s\" />\n" - "</filter>\n", a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), cutout.str().c_str(), blur.str().c_str()); - - return _filter; -}; /* Silhouette filter */ - -/** - \brief Custom predefined Specular light filter. - - Basic specular bevel to use for building textures - - Filter's parameters: - * Smoothness (0.0->10., default 6.) -> blur (stdDeviation) - * Brightness (0.0->5., default 1.) -> specular (specularConstant) - * Elevation (0->360, default 45) -> feDistantLight (elevation) - * Azimuth (0->360, default 235) -> feDistantLight (azimuth) - * Lighting color (guint, default -1 [white]) -> specular (lighting-color) -*/ - -class SpecularLight : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - SpecularLight ( ) : Filter() { }; - virtual ~SpecularLight ( ) { 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_("Specular light, custom (ABCs)") "</name>\n" - "<id>org.inkscape.effect.filter.SpecularLight</id>\n" - "<param name=\"smooth\" gui-text=\"" N_("Smoothness:") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"10\">6</param>\n" - "<param name=\"bright\" gui-text=\"" N_("Brightness:") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"5\">1</param>\n" - "<param name=\"elevation\" gui-text=\"" N_("Elevation (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">45</param>\n" - "<param name=\"azimuth\" gui-text=\"" N_("Azimuth (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">235</param>\n" - "<param name=\"color\" gui-text=\"" N_("Lighting color") "\" type=\"color\">-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_("Basic specular bevel to use for building textures") "</menu-tip>\n" - "</effect>\n" - "</inkscape-extension>\n", new SpecularLight()); - }; - -}; - -gchar const * -SpecularLight::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream smooth; - std::ostringstream bright; - std::ostringstream elevation; - std::ostringstream azimuth; - std::ostringstream r; - std::ostringstream g; - std::ostringstream b; - std::ostringstream a; - - smooth << ext->get_param_float("smooth"); - bright << ext->get_param_float("bright"); - elevation << ext->get_param_int("elevation"); - azimuth << ext->get_param_int("azimuth"); - guint32 color = ext->get_param_color("color"); - - r << ((color >> 24) & 0xff); - g << ((color >> 16) & 0xff); - b << ((color >> 8) & 0xff); - a << (color & 0xff) / 255.0F; - - _filter = g_strdup_printf( - "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Specular light, custom\">\n" - "<feGaussianBlur in=\"SourceAlpha\" stdDeviation=\"%s\" result=\"blur\" />\n" - "<feSpecularLighting in=\"blur\" specularExponent=\"25\" specularConstant=\"%s\" surfaceScale=\"10\" lighting-color=\"rgb(%s,%s,%s)\" result=\"specular\">\n" - "<feDistantLight elevation=\"%s\" azimuth=\"%s\" />\n" - "</feSpecularLighting>\n" - "<feComposite in=\"specular\" in2=\"SourceGraphic\" k3=\"1\" k2=\"%s\" operator=\"arithmetic\" result=\"composite1\" />\n" - "<feComposite in=\"composite1\" in2=\"SourceAlpha\" operator=\"in\" result=\"composite2\" />\n" - "</filter>\n", smooth.str().c_str(), bright.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), elevation.str().c_str(), azimuth.str().c_str(), a.str().c_str()); - - return _filter; -}; /* SpecularLight filter */ - - -}; /* namespace Filter */ -}; /* namespace Internal */ -}; /* namespace Extension */ -}; /* namespace Inkscape */ - -/* Change the 'ABC' below to be your file name */ -#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_ABC_H__ */ diff --git a/src/extension/internal/filter/blurs.h b/src/extension/internal/filter/blurs.h index 0fa15dfe6..d6f9a79e6 100644 --- a/src/extension/internal/filter/blurs.h +++ b/src/extension/internal/filter/blurs.h @@ -9,7 +9,9 @@ * * Blur filters * Blur + * Clean edges * Cross blur + * Feather * Image blur * * Released under GNU GPL, read the file 'COPYING' for more information @@ -48,7 +50,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" - "<name>" N_("Blur, custom (Blurs)") "</name>\n" + "<name>" N_("Blur") "</name>\n" "<id>org.inkscape.effect.filter.Blur</id>\n" "<param name=\"hblur\" gui-text=\"" N_("Horizontal blur:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.00\">2</param>\n" "<param name=\"vblur\" gui-text=\"" N_("Vertical blur:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.00\">2</param>\n" @@ -56,7 +58,7 @@ public: "<object-type>all</object-type>\n" "<effects-menu>\n" "<submenu name=\"" N_("Filters") "\">\n" - "<submenu name=\"" N_("Experimental") "\"/>\n" + "<submenu name=\"" N_("Blurs") "\"/>\n" "</submenu>\n" "</effects-menu>\n" "<menu-tip>" N_("Simple vertical and horizontal blur effect") "</menu-tip>\n" @@ -78,13 +80,68 @@ Blur::get_filter_text (Inkscape::Extension::Extension * ext) vblur << ext->get_param_float("vblur"); _filter = g_strdup_printf( - "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Blur, custom\">\n" + "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Blur\">\n" "<feGaussianBlur stdDeviation=\"%s %s\" result=\"blur\" />\n" "</filter>\n", hblur.str().c_str(), vblur.str().c_str()); return _filter; }; /* Blur filter */ +/** + \brief Custom predefined Clean edges filter. + + Removes or decreases glows and jaggeries around objects edges after applying some filters + + Filter's parameters: + * Strength (0.01->2., default 0.4) -> blur (stdDeviation) +*/ + +class CleanEdges : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + CleanEdges ( ) : Filter() { }; + virtual ~CleanEdges ( ) { 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_("Clean edges") "</name>\n" + "<id>org.inkscape.effect.filter.CleanEdges</id>\n" + "<param name=\"blur\" gui-text=\"" N_("Strength:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"2.00\">0.4</param>\n" + "<effect>\n" + "<object-type>all</object-type>\n" + "<effects-menu>\n" + "<submenu name=\"" N_("Filters") "\">\n" + "<submenu name=\"" N_("Blurs") "\"/>\n" + "</submenu>\n" + "</effects-menu>\n" + "<menu-tip>" N_("Removes or decreases glows and jaggeries around objects edges after applying some filters") "</menu-tip>\n" + "</effect>\n" + "</inkscape-extension>\n", new CleanEdges()); + }; + +}; + +gchar const * +CleanEdges::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream blur; + + blur << ext->get_param_float("blur"); + + _filter = g_strdup_printf( + "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Clean edges\">\n" + "<feGaussianBlur stdDeviation=\"%s\" result=\"blur\" />\n" + "<feComposite in=\"SourceGraphic\" in2=\"blur\" operator=\"in\" result=\"composite1\" />\n" + "<feComposite in=\"composite1\" in2=\"composite1\" k2=\"1\" operator=\"in\" result=\"composite2\" />\n" + "</filter>\n", blur.str().c_str()); + + return _filter; +}; /* CleanEdges filter */ /** \brief Custom predefined Cross blur filter. @@ -110,7 +167,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" - "<name>" N_("Cross blur, custom (Blurs)") "</name>\n" + "<name>" N_("Cross blur") "</name>\n" "<id>org.inkscape.effect.filter.CrossBlur</id>\n" "<param name=\"bright\" gui-text=\"" N_("Brightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"10.00\">0</param>\n" "<param name=\"fade\" gui-text=\"" N_("Fading:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1.00\">0</param>\n" @@ -126,7 +183,7 @@ public: "<object-type>all</object-type>\n" "<effects-menu>\n" "<submenu name=\"" N_("Filters") "\">\n" - "<submenu name=\"" N_("Experimental") "\"/>\n" + "<submenu name=\"" N_("Blurs") "\"/>\n" "</submenu>\n" "</effects-menu>\n" "<menu-tip>" N_("Combine vertical and horizontal blur") "</menu-tip>\n" @@ -154,7 +211,7 @@ CrossBlur::get_filter_text (Inkscape::Extension::Extension * ext) blend << ext->get_param_enum("blend"); _filter = g_strdup_printf( - "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Cross blur, custom\">\n" + "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Cross blur\">\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=\"colormatrix\" />\n" "<feComposite in=\"SourceGraphic\" in2=\"colormatrix\" operator=\"arithmetic\" k2=\"1\" k3=\"%s\" k4=\"%s\" result=\"composite\" />\n" "<feGaussianBlur stdDeviation=\"%s 0.01\" result=\"blur1\" />\n" @@ -165,6 +222,62 @@ CrossBlur::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Cross blur filter */ +/** + \brief Custom predefined Feather filter. + + Blurred mask on the edge without altering the contents + + Filter's parameters: + * Strength (0.01->100., default 5) -> blur (stdDeviation) +*/ + +class Feather : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + Feather ( ) : Filter() { }; + virtual ~Feather ( ) { 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_("Feather") "</name>\n" + "<id>org.inkscape.effect.filter.Feather</id>\n" + "<param name=\"blur\" gui-text=\"" N_("Strength:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.00\">5</param>\n" + "<effect>\n" + "<object-type>all</object-type>\n" + "<effects-menu>\n" + "<submenu name=\"" N_("Filters") "\">\n" + "<submenu name=\"" N_("Blurs") "\"/>\n" + "</submenu>\n" + "</effects-menu>\n" + "<menu-tip>" N_("Blurred mask on the edge without altering the contents") "</menu-tip>\n" + "</effect>\n" + "</inkscape-extension>\n", new Feather()); + }; + +}; + +gchar const * +Feather::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream blur; + + blur << ext->get_param_float("blur"); + + _filter = g_strdup_printf( + "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Feather\">\n" + "<feGaussianBlur stdDeviation=\"%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" + "</filter>\n", blur.str().c_str()); + + return _filter; +}; /* Feather filter */ /** \brief Custom predefined Image blur filter. @@ -194,7 +307,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" - "<name>" N_("Image blur, custom (Blurs)") "</name>\n" + "<name>" N_("Image blur") "</name>\n" "<id>org.inkscape.effect.filter.ImageBlur</id>\n" "<param name=\"tab\" type=\"notebook\">\n" "<page name=\"optionstab\" _gui-text=\"Options\">\n" @@ -220,7 +333,7 @@ public: "<object-type>all</object-type>\n" "<effects-menu>\n" "<submenu name=\"" N_("Filters") "\">\n" - "<submenu name=\"" N_("Experimental") "\"/>\n" + "<submenu name=\"" N_("Blurs") "\"/>\n" "</submenu>\n" "</effects-menu>\n" "<menu-tip>" N_("Blur eroded by white or transparency") "</menu-tip>\n" @@ -267,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, custom\">\n" + "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Image blur\">\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" @@ -282,8 +395,6 @@ ImageBlur::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Image blur filter */ - - }; /* namespace Filter */ }; /* namespace Internal */ }; /* namespace Extension */ diff --git a/src/extension/internal/filter/bumps.h b/src/extension/internal/filter/bumps.h index b52581844..596d1547f 100644 --- a/src/extension/internal/filter/bumps.h +++ b/src/extension/internal/filter/bumps.h @@ -9,6 +9,9 @@ * * Bump filters * Bump + * Diffuse light + * Matte jelly + * Specular light * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -76,7 +79,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" - "<name>" N_("Bump, custom (Bumps)") "</name>\n" + "<name>" N_("Bump") "</name>\n" "<id>org.inkscape.effect.filter.Bump</id>\n" "<param name=\"tab\" type=\"notebook\">\n" "<page name=\"optionstab\" _gui-text=\"Options\">\n" @@ -138,7 +141,7 @@ public: "<object-type>all</object-type>\n" "<effects-menu>\n" "<submenu name=\"" N_("Filters") "\">\n" - "<submenu name=\"" N_("Experimental") "\"/>\n" + "<submenu name=\"" N_("Bumps") "\"/>\n" "</submenu>\n" "</effects-menu>\n" "<menu-tip>" N_("All purposes bump filter") "</menu-tip>\n" @@ -241,7 +244,7 @@ Bump::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.2\" width=\"1.2\" y=\"-0.1\" x=\"-0.1\" inkscape:label=\"Bump, custom\">\n" + "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1.2\" width=\"1.2\" y=\"-0.1\" x=\"-0.1\" inkscape:label=\"Bump\">\n" "<feGaussianBlur in=\"SourceGraphic\" stdDeviation=\"%s\" result=\"blur1\" />\n" "<feColorMatrix in=\"%s\" values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 %s %s %s 1 0 \" result=\"colormatrix1\" />\n" "<feColorMatrix in=\"colormatrix1\" type=\"luminanceToAlpha\" result=\"colormatrix2\" />\n" @@ -262,8 +265,253 @@ Bump::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; -}; /* Cross blur filter */ +}; /* Bump filter */ +/** + \brief Custom predefined Diffuse light filter. + + Basic diffuse bevel to use for building textures + + Filter's parameters: + * Smoothness (0.->10., default 6.) -> blur (stdDeviation) + * Elevation (0->360, default 25) -> feDistantLight (elevation) + * Azimuth (0->360, default 235) -> feDistantLight (azimuth) + * Lighting color (guint, default -1 [white]) -> diffuse (lighting-color) +*/ + +class DiffuseLight : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + DiffuseLight ( ) : Filter() { }; + virtual ~DiffuseLight ( ) { 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_("Diffuse light") "</name>\n" + "<id>org.inkscape.effect.filter.DiffuseLight</id>\n" + "<param name=\"smooth\" gui-text=\"" N_("Smoothness:") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"10\">6</param>\n" + "<param name=\"elevation\" gui-text=\"" N_("Elevation (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">25</param>\n" + "<param name=\"azimuth\" gui-text=\"" N_("Azimuth (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">235</param>\n" + "<param name=\"color\" gui-text=\"" N_("Lighting color") "\" type=\"color\">-1</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_("Basic diffuse bevel to use for building textures") "</menu-tip>\n" + "</effect>\n" + "</inkscape-extension>\n", new DiffuseLight()); + }; + +}; + +gchar const * +DiffuseLight::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream smooth; + std::ostringstream elevation; + std::ostringstream azimuth; + std::ostringstream r; + std::ostringstream g; + std::ostringstream b; + std::ostringstream a; + + smooth << ext->get_param_float("smooth"); + elevation << ext->get_param_int("elevation"); + azimuth << ext->get_param_int("azimuth"); + guint32 color = ext->get_param_color("color"); + + r << ((color >> 24) & 0xff); + g << ((color >> 16) & 0xff); + b << ((color >> 8) & 0xff); + a << (color & 0xff) / 255.0F; + + _filter = g_strdup_printf( + "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Diffuse light\">\n" + "<feGaussianBlur in=\"SourceGraphic\" stdDeviation=\"%s\" result=\"blur\" />\n" + "<feDiffuseLighting diffuseConstant=\"1\" surfaceScale=\"10\" lighting-color=\"rgb(%s,%s,%s)\" result=\"diffuse\">\n" + "<feDistantLight elevation=\"%s\" azimuth=\"%s\" />\n" + "</feDiffuseLighting>\n" + "<feComposite in=\"diffuse\" in2=\"diffuse\" operator=\"arithmetic\" k1=\"1\" result=\"composite1\" />\n" + "<feComposite in=\"composite1\" in2=\"SourceGraphic\" k1=\"%s\" operator=\"arithmetic\" k3=\"1\" result=\"composite2\" />\n" + "</filter>\n", smooth.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), elevation.str().c_str(), azimuth.str().c_str(), a.str().c_str()); + + return _filter; +}; /* DiffuseLight filter */ + +/** + \brief Custom predefined Matte jelly filter. + + Bulging, matte jelly covering + + Filter's parameters: + * Smoothness (0.0->10., default 7.) -> blur (stdDeviation) + * Brightness (0.0->5., default .9) -> specular (specularConstant) + * Elevation (0->360, default 60) -> feDistantLight (elevation) + * Azimuth (0->360, default 225) -> feDistantLight (azimuth) + * Lighting color (guint, default -1 [white]) -> specular (lighting-color) +*/ + +class MatteJelly : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + MatteJelly ( ) : Filter() { }; + virtual ~MatteJelly ( ) { 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_("Matte jelly") "</name>\n" + "<id>org.inkscape.effect.filter.MatteJelly</id>\n" + "<param name=\"smooth\" gui-text=\"" N_("Smoothness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"10.00\">7</param>\n" + "<param name=\"bright\" gui-text=\"" N_("Brightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"5.00\">0.9</param>\n" + "<param name=\"elevation\" gui-text=\"" N_("Elevation (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">60</param>\n" + "<param name=\"azimuth\" gui-text=\"" N_("Azimuth (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">225</param>\n" + "<param name=\"color\" gui-text=\"" N_("Lighting color") "\" type=\"color\">-1</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_("Bulging, matte jelly covering") "</menu-tip>\n" + "</effect>\n" + "</inkscape-extension>\n", new MatteJelly()); + }; + +}; + +gchar const * +MatteJelly::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream smooth; + std::ostringstream bright; + std::ostringstream elevation; + std::ostringstream azimuth; + std::ostringstream r; + std::ostringstream g; + std::ostringstream b; + std::ostringstream a; + + smooth << ext->get_param_float("smooth"); + bright << ext->get_param_float("bright"); + elevation << ext->get_param_int("elevation"); + azimuth << ext->get_param_int("azimuth"); + guint32 color = ext->get_param_color("color"); + + r << ((color >> 24) & 0xff); + g << ((color >> 16) & 0xff); + b << ((color >> 8) & 0xff); + a << (color & 0xff) / 255.0F; + + _filter = g_strdup_printf( + "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Matte jelly\">\n" + "<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0.85 0\" result=\"color\" in=\"SourceGraphic\" />\n" + "<feGaussianBlur in=\"SourceAlpha\" stdDeviation=\"%s\" result=\"blur\" />\n" + "<feSpecularLighting in=\"blur\" specularExponent=\"25\" specularConstant=\"%s\" surfaceScale=\"5\" lighting-color=\"rgb(%s,%s,%s)\" result=\"specular\">\n" + "<feDistantLight elevation=\"%s\" azimuth=\"%s\" />\n" + "</feSpecularLighting>\n" + "<feComposite in=\"specular\" in2=\"SourceGraphic\" k3=\"1\" k2=\"%s\" operator=\"arithmetic\" result=\"composite1\" />\n" + "<feComposite in=\"composite1\" in2=\"color\" operator=\"atop\" result=\"composite2\" />\n" + "</filter>\n", smooth.str().c_str(), bright.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), elevation.str().c_str(), azimuth.str().c_str(), a.str().c_str()); + + return _filter; +}; /* MatteJelly filter */ + +/** + \brief Custom predefined Specular light filter. + + Basic specular bevel to use for building textures + + Filter's parameters: + * Smoothness (0.0->10., default 6.) -> blur (stdDeviation) + * Brightness (0.0->5., default 1.) -> specular (specularConstant) + * Elevation (0->360, default 45) -> feDistantLight (elevation) + * Azimuth (0->360, default 235) -> feDistantLight (azimuth) + * Lighting color (guint, default -1 [white]) -> specular (lighting-color) +*/ + +class SpecularLight : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + SpecularLight ( ) : Filter() { }; + virtual ~SpecularLight ( ) { 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_("Specular light") "</name>\n" + "<id>org.inkscape.effect.filter.SpecularLight</id>\n" + "<param name=\"smooth\" gui-text=\"" N_("Smoothness:") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"10\">6</param>\n" + "<param name=\"bright\" gui-text=\"" N_("Brightness:") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"5\">1</param>\n" + "<param name=\"elevation\" gui-text=\"" N_("Elevation (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">45</param>\n" + "<param name=\"azimuth\" gui-text=\"" N_("Azimuth (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">235</param>\n" + "<param name=\"color\" gui-text=\"" N_("Lighting color") "\" type=\"color\">-1</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_("Basic specular bevel to use for building textures") "</menu-tip>\n" + "</effect>\n" + "</inkscape-extension>\n", new SpecularLight()); + }; + +}; + +gchar const * +SpecularLight::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream smooth; + std::ostringstream bright; + std::ostringstream elevation; + std::ostringstream azimuth; + std::ostringstream r; + std::ostringstream g; + std::ostringstream b; + std::ostringstream a; + + smooth << ext->get_param_float("smooth"); + bright << ext->get_param_float("bright"); + elevation << ext->get_param_int("elevation"); + azimuth << ext->get_param_int("azimuth"); + guint32 color = ext->get_param_color("color"); + + r << ((color >> 24) & 0xff); + g << ((color >> 16) & 0xff); + b << ((color >> 8) & 0xff); + a << (color & 0xff) / 255.0F; + + _filter = g_strdup_printf( + "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Specular light\">\n" + "<feGaussianBlur in=\"SourceAlpha\" stdDeviation=\"%s\" result=\"blur\" />\n" + "<feSpecularLighting in=\"blur\" specularExponent=\"25\" specularConstant=\"%s\" surfaceScale=\"10\" lighting-color=\"rgb(%s,%s,%s)\" result=\"specular\">\n" + "<feDistantLight elevation=\"%s\" azimuth=\"%s\" />\n" + "</feSpecularLighting>\n" + "<feComposite in=\"specular\" in2=\"SourceGraphic\" k3=\"1\" k2=\"%s\" operator=\"arithmetic\" result=\"composite1\" />\n" + "<feComposite in=\"composite1\" in2=\"SourceAlpha\" operator=\"in\" result=\"composite2\" />\n" + "</filter>\n", smooth.str().c_str(), bright.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), elevation.str().c_str(), azimuth.str().c_str(), a.str().c_str()); + + return _filter; +}; /* SpecularLight filter */ }; /* namespace Filter */ }; /* namespace Internal */ diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index 7be675bec..e8de022b9 100755..100644 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -10,7 +10,7 @@ * Color filters * Brightness * Channel painting - * Channel transparency + * Color shift * Colorize * Duochrome * Electrize @@ -63,7 +63,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" - "<name>" N_("Brightness, custom (Color)") "</name>\n" + "<name>" N_("Brightness") "</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" @@ -73,7 +73,7 @@ public: "<object-type>all</object-type>\n" "<effects-menu>\n" "<submenu name=\"" N_("Filters") "\">\n" - "<submenu name=\"" N_("Experimental") "\"/>\n" + "<submenu name=\"" N_("Color") "\"/>\n" "</submenu>\n" "</effects-menu>\n" "<menu-tip>" N_("Brightness filter") "</menu-tip>\n" @@ -112,7 +112,6 @@ Brightness::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Brightness filter */ - /** \brief Custom predefined Channel Painting filter. @@ -144,7 +143,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" - "<name>" N_("Channel painting, custom (Color)") "</name>\n" + "<name>" N_("Channel painting") "</name>\n" "<id>org.inkscape.effect.filter.ChannelPaint</id>\n" "<param name=\"tab\" type=\"notebook\">\n" "<page name=\"optionstab\" _gui-text=\"Options\">\n" @@ -163,7 +162,7 @@ public: "<object-type>all</object-type>\n" "<effects-menu>\n" "<submenu name=\"" N_("Filters") "\">\n" - "<submenu name=\"" N_("Experimental") "\"/>\n" + "<submenu name=\"" N_("Color") "\"/>\n" "</submenu>\n" "</effects-menu>\n" "<menu-tip>" N_("Replace RGB by any color") "</menu-tip>\n" @@ -225,90 +224,64 @@ ChannelPaint::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Channel Painting filter */ - /** - \brief Custom predefined Channel transparency filter. + \brief Custom predefined Color shift filter. - Channel transparency filter. + Rotate and desaturate hue Filter's parameters: - * Saturation (0.->1., default 1.) -> colormatrix1 (values) - * Red (-10.->10., default -1.) -> colormatrix2 (values) - * Green (-10.->10., default 0.5) -> colormatrix2 (values) - * Blue (-10.->10., default 0.5) -> colormatrix2 (values) - * Alpha (-10.->10., default 1.) -> colormatrix2 (values) - * Flood colors (guint, default 16777215) -> flood (flood-opacity, flood-color) - * Inverted (boolean, default false) -> composite1 (operator, true='in', false='out') - - Matrix: - 1 0 0 0 0 - 0 1 0 0 0 - 0 0 1 0 0 - R G B A 0 + * Shift (0->360, default 330) -> color1 (values) + * Saturation (0.->1., default 0.6) -> color2 (values) */ -class ChannelTransparency : public Inkscape::Extension::Internal::Filter::Filter { + +class ColorShift : public Inkscape::Extension::Internal::Filter::Filter { protected: virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); public: - ChannelTransparency ( ) : Filter() { }; - virtual ~ChannelTransparency ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - + ColorShift ( ) : Filter() { }; + virtual ~ColorShift ( ) { 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_("Channel transparency, custom (Color)") "</name>\n" - "<id>org.inkscape.effect.filter.ChannelTransparency</id>\n" - "<param name=\"red\" gui-text=\"" N_("Red:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.00\" max=\"10.00\">-1</param>\n" - "<param name=\"green\" gui-text=\"" N_("Green:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.00\" max=\"10.00\">0.5</param>\n" - "<param name=\"blue\" gui-text=\"" N_("Blue:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.00\" max=\"10.00\">0.5</param>\n" - "<param name=\"alpha\" gui-text=\"" N_("Alpha:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1.\">1</param>\n" - "<param name=\"invert\" gui-text=\"" N_("Inverted") "\" type=\"boolean\">false</param>\n" + "<name>" N_("Color shift") "</name>\n" + "<id>org.inkscape.effect.filter.ColorShift</id>\n" + "<param name=\"shift\" gui-text=\"" N_("Shift (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">330</param>\n" + "<param name=\"sat\" gui-text=\"" N_("Saturation:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1\">0.6</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" "<submenu name=\"" N_("Filters") "\">\n" - "<submenu name=\"" N_("Experimental") "\"/>\n" + "<submenu name=\"" N_("Color") "\"/>\n" "</submenu>\n" "</effects-menu>\n" - "<menu-tip>" N_("Replace RGB by transparency") "</menu-tip>\n" + "<menu-tip>" N_("Rotate and desaturate hue") "</menu-tip>\n" "</effect>\n" - "</inkscape-extension>\n", new ChannelTransparency()); + "</inkscape-extension>\n", new ColorShift()); }; + }; gchar const * -ChannelTransparency::get_filter_text (Inkscape::Extension::Extension * ext) +ColorShift::get_filter_text (Inkscape::Extension::Extension * ext) { if (_filter != NULL) g_free((void *)_filter); - std::ostringstream red; - std::ostringstream green; - std::ostringstream blue; - std::ostringstream alpha; - std::ostringstream invert; + std::ostringstream shift; + std::ostringstream sat; - red << ext->get_param_float("red"); - green << ext->get_param_float("green"); - blue << ext->get_param_float("blue"); - alpha << ext->get_param_float("alpha"); + shift << ext->get_param_int("shift"); + sat << ext->get_param_float("sat"); - if (!ext->get_param_bool("invert")) { - invert << "in"; - } else { - invert << "xor"; - } - _filter = g_strdup_printf( - "<filter inkscape:label=\"Color channel painting\" color-interpolation-filters=\"sRGB\" x=\"0\" y=\"0\" width=\"1\" height=\"1\">\n" - "<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 %s %s %s %s 0 \" in=\"SourceGraphic\" result=\"colormatrix\" />\n" - "<feComposite in=\"colormatrix\" in2=\"SourceGraphic\" operator=\"%s\" result=\"composite1\" />\n" - "</filter>\n", red.str().c_str(), green.str().c_str(), blue.str().c_str(), alpha.str().c_str(), - invert.str().c_str()); + "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Color shift\">\n" + "<feColorMatrix type=\"hueRotate\" values=\"%s\" result=\"color1\" />\n" + "<feColorMatrix type=\"saturate\" values=\"%s\" result=\"color2\" />\n" + "</filter>\n", shift.str().c_str(), sat.str().c_str()); return _filter; -}; /* Channel Transparency filter */ - +}; /* ColorShift filter */ /** \brief Custom predefined Colorize filter. @@ -335,7 +308,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" - "<name>" N_("Colorize, custom (Color)") "</name>\n" + "<name>" N_("Colorize") "</name>\n" "<id>org.inkscape.effect.filter.Colorize</id>\n" "<param name=\"tab\" type=\"notebook\">\n" "<page name=\"optionstab\" _gui-text=\"Options\">\n" @@ -365,7 +338,7 @@ public: "<object-type>all</object-type>\n" "<effects-menu>\n" "<submenu name=\"" N_("Filters") "\">\n" - "<submenu name=\"" N_("Experimental") "\"/>\n" + "<submenu name=\"" N_("Color") "\"/>\n" "</submenu>\n" "</effects-menu>\n" "<menu-tip>" N_("Blend image or object with a flood color") "</menu-tip>\n" @@ -420,7 +393,6 @@ Colorize::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Colorize filter */ - /** \brief Custom predefined Duochrome filter. @@ -444,7 +416,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" - "<name>" N_("Duochrome, custom (Color)") "</name>\n" + "<name>" N_("Duochrome") "</name>\n" "<id>org.inkscape.effect.filter.Duochrome</id>\n" "<param name=\"tab\" type=\"notebook\">\n" "<page name=\"optionstab\" _gui-text=\"Options\">\n" @@ -467,7 +439,7 @@ public: "<object-type>all</object-type>\n" "<effects-menu>\n" "<submenu name=\"" N_("Filters") "\">\n" - "<submenu name=\"" N_("Experimental") "\"/>\n" + "<submenu name=\"" N_("Color") "\"/>\n" "</submenu>\n" "</effects-menu>\n" "<menu-tip>" N_("Convert luminance values to a duochrome palette") "</menu-tip>\n" @@ -567,7 +539,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" - "<name>" N_("Electrize, custom (Color)") "</name>\n" + "<name>" N_("Electrize") "</name>\n" "<id>org.inkscape.effect.filter.Electrize</id>\n" "<param name=\"blur\" gui-text=\"" N_("Simplify:") "\" type=\"float\" appearance=\"full\" min=\"0.01\" max=\"10.0\">2.0</param>\n" "<param name=\"type\" gui-text=\"" N_("Effect type:") "\" type=\"enum\">\n" @@ -580,7 +552,7 @@ public: "<object-type>all</object-type>\n" "<effects-menu>\n" "<submenu name=\"" N_("Filters") "\">\n" - "<submenu name=\"" N_("Experimental") "\"/>\n" + "<submenu name=\"" N_("Color") "\"/>\n" "</submenu>\n" "</effects-menu>\n" "<menu-tip>" N_("Electro solarization effects") "</menu-tip>\n" @@ -661,7 +633,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" - "<name>" N_("Greyscale, custom (Color)") "</name>\n" + "<name>" N_("Greyscale") "</name>\n" "<id>org.inkscape.effect.filter.Greyscale</id>\n" "<param name=\"red\" gui-text=\"" N_("Red:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.00\" max=\"10.00\">0.21</param>\n" "<param name=\"green\" gui-text=\"" N_("Green:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.00\" max=\"10.00\">0.72</param>\n" @@ -672,7 +644,7 @@ public: "<object-type>all</object-type>\n" "<effects-menu>\n" "<submenu name=\"" N_("Filters") "\">\n" - "<submenu name=\"" N_("Experimental") "\"/>\n" + "<submenu name=\"" N_("Color") "\"/>\n" "</submenu>\n" "</effects-menu>\n" "<menu-tip>" N_("Customize greyscale components") "</menu-tip>\n" @@ -743,7 +715,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" - "<name>" N_("Lightness, custom (Color)") "</name>\n" + "<name>" N_("Lightness") "</name>\n" "<id>org.inkscape.effect.filter.Lightness</id>\n" "<param name=\"amplitude\" gui-text=\"" N_("Lights:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"20.00\">1</param>\n" "<param name=\"exponent\" gui-text=\"" N_("Shadows:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"20.00\">1</param>\n" @@ -752,7 +724,7 @@ public: "<object-type>all</object-type>\n" "<effects-menu>\n" "<submenu name=\"" N_("Filters") "\">\n" - "<submenu name=\"" N_("Experimental") "\"/>\n" + "<submenu name=\"" N_("Color") "\"/>\n" "</submenu>\n" "</effects-menu>\n" "<menu-tip>" N_("Modify lights and shadows separately") "</menu-tip>\n" @@ -812,7 +784,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" - "<name>" N_("Quadritone fantasy, custom (Color)") "</name>\n" + "<name>" N_("Quadritone fantasy") "</name>\n" "<id>org.inkscape.effect.filter.Quadritone</id>\n" "<param name=\"dist\" gui-text=\"" N_("Hue distribution (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">280</param>\n" "<param name=\"colors\" gui-text=\"" N_("Colors:") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">100</param>\n" @@ -833,7 +805,7 @@ public: "<object-type>all</object-type>\n" "<effects-menu>\n" "<submenu name=\"" N_("Filters") "\">\n" - "<submenu name=\"" N_("Experimental") "\"/>\n" + "<submenu name=\"" N_("Color") "\"/>\n" "</submenu>\n" "</effects-menu>\n" "<menu-tip>" N_("Replace hue by two colors") "</menu-tip>\n" @@ -874,7 +846,6 @@ Quadritone::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Quadritone filter */ - /** \brief Custom predefined Solarize filter. @@ -899,7 +870,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" - "<name>" N_("Solarize, custom (Color)") "</name>\n" + "<name>" N_("Solarize") "</name>\n" "<id>org.inkscape.effect.filter.Solarize</id>\n" "<param name=\"rotate\" gui-text=\"" N_("Hue rotation (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">0</param>\n" "<param name=\"type\" gui-text=\"" N_("Type:") "\" type=\"enum\">\n" @@ -910,7 +881,7 @@ public: "<object-type>all</object-type>\n" "<effects-menu>\n" "<submenu name=\"" N_("Filters") "\">\n" - "<submenu name=\"" N_("Experimental") "\"/>\n" + "<submenu name=\"" N_("Color") "\"/>\n" "</submenu>\n" "</effects-menu>\n" "<menu-tip>" N_("Classic photographic solarization effect") "</menu-tip>\n" @@ -954,7 +925,6 @@ Solarize::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Solarize filter */ - /** \brief Custom predefined Tritone filter. @@ -986,7 +956,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" - "<name>" N_("Tritone, custom (Color)") "</name>\n" + "<name>" N_("Tritone") "</name>\n" "<id>org.inkscape.effect.filter.Tritone</id>\n" "<param name=\"tab\" type=\"notebook\">\n" "<page name=\"optionstab\" _gui-text=\"Options\">\n" @@ -1020,7 +990,7 @@ public: "<object-type>all</object-type>\n" "<effects-menu>\n" "<submenu name=\"" N_("Filters") "\">\n" - "<submenu name=\"" N_("Experimental") "\"/>\n" + "<submenu name=\"" N_("Color") "\"/>\n" "</submenu>\n" "</effects-menu>\n" "<menu-tip>" N_("Create a custom tritone palette with additional glow, blend modes and hue moving") "</menu-tip>\n" diff --git a/src/extension/internal/filter/distort.h b/src/extension/internal/filter/distort.h new file mode 100644 index 000000000..7157722d7 --- /dev/null +++ b/src/extension/internal/filter/distort.h @@ -0,0 +1,112 @@ +#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_DISTORT_H__ +#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_DISTORT_H__ +/* Change the 'DISTORT' above to be your file name */ + +/* + * Copyright (C) 2011 Authors: + * Ivan Louette (filters) + * Nicolas Dufour (UI) <nicoduf@yahoo.fr> + * + * Distort filters + * Roughen + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ +/* ^^^ Change the copyright to be you and your e-mail address ^^^ */ + +#include "filter.h" + +#include "extension/internal/clear-n_.h" +#include "extension/system.h" +#include "extension/extension.h" + +namespace Inkscape { +namespace Extension { +namespace Internal { +namespace 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]) + * Complexity (1->5, default 5) -> turbulence (numOctaves) + * Variation (1->360, default 1) -> turbulence (seed) + * Intensity (0.0->50., default 6.6) -> displacement (scale) +*/ + +class Roughen : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + Roughen ( ) : Filter() { }; + virtual ~Roughen ( ) { 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_("Roughen") "</name>\n" + "<id>org.inkscape.effect.filter.Roughen</id>\n" + "<param name=\"type\" gui-text=\"" N_("Turbulence type:") "\" 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=\"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=\"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" + "<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_("Small-scale roughening to edges and content") "</menu-tip>\n" + "</effect>\n" + "</inkscape-extension>\n", new Roughen()); + }; + +}; + +gchar const * +Roughen::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream type; + std::ostringstream hfreq; + std::ostringstream vfreq; + std::ostringstream complexity; + std::ostringstream variation; + std::ostringstream intensity; + + type << ext->get_param_enum("type"); + hfreq << (ext->get_param_float("hfreq") / 1000); + vfreq << (ext->get_param_float("vfreq") / 1000); + complexity << ext->get_param_int("complexity"); + variation << ext->get_param_int("variation"); + intensity << ext->get_param_float("intensity"); + + _filter = g_strdup_printf( + "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Roughen\">\n" + "<feTurbulence type=\"%s\" numOctaves=\"%s\" seed=\"%s\" baseFrequency=\"%s %s\" result=\"turbulence\" />\n" + "<feDisplacementMap in=\"SourceGraphic\" in2=\"turbulence\" scale=\"%s\" yChannelSelector=\"G\" xChannelSelector=\"R\" />\n" + "</filter>\n", type.str().c_str(), complexity.str().c_str(), variation.str().c_str(), hfreq.str().c_str(), vfreq.str().c_str(), intensity.str().c_str()); + + return _filter; +}; /* Roughen filter */ + +}; /* namespace Filter */ +}; /* namespace Internal */ +}; /* namespace Extension */ +}; /* namespace Inkscape */ + +/* Change the 'DISTORT' below to be your file name */ +#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_DISTORT_H__ */ diff --git a/src/extension/internal/filter/drop-shadow.h b/src/extension/internal/filter/drop-shadow.h deleted file mode 100644 index c2338d194..000000000 --- a/src/extension/internal/filter/drop-shadow.h +++ /dev/null @@ -1,150 +0,0 @@ -#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_DROP_SHADOW_H__ -#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_DROP_SHADOW_H__ -/* Change the 'DROP_SHADOW' above to be your file name */ - -/* - * Copyright (C) 2008 Authors: - * Ted Gould <ted@gould.cx> - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ -/* ^^^ Change the copyright to be you and your e-mail address ^^^ */ - -#include "filter.h" - -#include "extension/internal/clear-n_.h" -#include "extension/system.h" -#include "extension/extension.h" - -namespace Inkscape { -namespace Extension { -namespace Internal { -namespace Filter { - -class DropShadow : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - DropShadow ( ) : Filter() { }; - virtual ~DropShadow ( ) { 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_("Drop Shadow") "</name>\n" - "<id>org.inkscape.effect.filter.drop-shadow</id>\n" - "<param name=\"blur\" gui-text=\"" N_("Blur radius (px):") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"200.0\">2.0</param>\n" - "<param name=\"opacity\" gui-text=\"" N_("Opacity (%):") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"100.0\">50</param>\n" - "<param name=\"xoffset\" gui-text=\"" N_("Horizontal offset (px):") "\" type=\"float\" appearance=\"full\" min=\"-50.0\" max=\"50.0\">4.0</param>\n" - "<param name=\"yoffset\" gui-text=\"" N_("Vertical offset (px):") "\" type=\"float\" appearance=\"full\" min=\"-50.0\" max=\"50.0\">4.0</param>\n" - "<effect>\n" - "<object-type>all</object-type>\n" - "<effects-menu>\n" - "<submenu name=\"" N_("Filters") "\" >\n" - "<submenu name=\"" N_("Shadows and Glows") "\"/>\n" - "</submenu>\n" - "</effects-menu>\n" - "<menu-tip>" N_("Black, blurred drop shadow") "</menu-tip>\n" - "</effect>\n" - "</inkscape-extension>\n", new DropShadow()); - }; - -}; - -gchar const * -DropShadow::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream blur; - std::ostringstream opacity; - std::ostringstream x; - std::ostringstream y; - - blur << ext->get_param_float("blur"); - opacity << ext->get_param_float("opacity") / 100; - x << ext->get_param_float("xoffset"); - y << ext->get_param_float("yoffset"); - - _filter = g_strdup_printf( - "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" inkscape:label=\"Drop shadow\" width=\"1.5\" height=\"1.5\" x=\"-.25\" y=\"-.25\">\n" - "<feGaussianBlur in=\"SourceAlpha\" stdDeviation=\"%s\" result=\"blur\"/>\n" - "<feColorMatrix result=\"bluralpha\" type=\"matrix\" values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 %s 0 \" />\n" - "<feOffset in=\"bluralpha\" dx=\"%s\" dy=\"%s\" result=\"offsetBlur\"/>\n" - "<feMerge>\n" - "<feMergeNode in=\"offsetBlur\"/>\n" - "<feMergeNode in=\"SourceGraphic\"/>\n" - "</feMerge>\n" - "</filter>\n", blur.str().c_str(), opacity.str().c_str(), x.str().c_str(), y.str().c_str()); - - return _filter; -}; - -class DropGlow : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - DropGlow ( ) : Filter() { }; - virtual ~DropGlow ( ) { 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_("Drop Glow") "</name>\n" - "<id>org.inkscape.effect.filter.drop-glow</id>\n" - "<param name=\"blur\" gui-text=\"" N_("Blur radius (px):") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"200.0\">2.0</param>\n" - "<param name=\"opacity\" gui-text=\"" N_("Opacity (%):") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"100.0\">50</param>\n" - "<param name=\"xoffset\" gui-text=\"" N_("Horizontal offset (px):") "\" type=\"float\" appearance=\"full\" min=\"-50.0\" max=\"50.0\">4.0</param>\n" - "<param name=\"yoffset\" gui-text=\"" N_("Vertical offset (px):") "\" type=\"float\" appearance=\"full\" min=\"-50.0\" max=\"50.0\">4.0</param>\n" - "<effect>\n" - "<object-type>all</object-type>\n" - "<effects-menu>\n" - "<submenu name=\"" N_("Filters") "\">\n" - "<submenu name=\"" N_("Shadows and Glows") "\"/>\n" - "</submenu>\n" - "</effects-menu>\n" - "<menu-tip>" N_("White, blurred drop glow") "</menu-tip>\n" - "</effect>\n" - "</inkscape-extension>\n", new DropGlow()); - }; - -}; - -gchar const * -DropGlow::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream blur; - std::ostringstream opacity; - std::ostringstream x; - std::ostringstream y; - - blur << ext->get_param_float("blur"); - opacity << ext->get_param_float("opacity") / 100; - x << ext->get_param_float("xoffset"); - y << ext->get_param_float("yoffset"); - - _filter = g_strdup_printf( - "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" inkscape:label=\"Drop shadow\" width=\"1.5\" height=\"1.5\" x=\"-.25\" y=\"-.25\">\n" - "<feGaussianBlur in=\"SourceAlpha\" stdDeviation=\"%s\" result=\"blur\"/>\n" - "<feColorMatrix result=\"bluralpha\" type=\"matrix\" values=\"-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 %s 0 \" />\n" - "<feOffset in=\"bluralpha\" dx=\"%s\" dy=\"%s\" result=\"offsetBlur\"/>\n" - "<feMerge>\n" - "<feMergeNode in=\"offsetBlur\"/>\n" - "<feMergeNode in=\"SourceGraphic\"/>\n" - "</feMerge>\n" - "</filter>\n", blur.str().c_str(), opacity.str().c_str(), x.str().c_str(), y.str().c_str()); - - return _filter; -}; - -}; /* namespace Filter */ -}; /* namespace Internal */ -}; /* namespace Extension */ -}; /* namespace Inkscape */ - -/* Change the 'DROP_SHADOW' below to be your file name */ -#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_DROP_SHADOW_H__ */ diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp index b451ac619..ffac97e0c 100755 --- a/src/extension/internal/filter/filter-all.cpp +++ b/src/extension/internal/filter/filter-all.cpp @@ -8,17 +8,17 @@ #include "filter.h" /* Put your filter here */ -#include "abc.h" #include "blurs.h" #include "bumps.h" #include "color.h" -#include "drop-shadow.h" +#include "distort.h" #include "image.h" #include "morphology.h" +#include "overlays.h" +#include "paint.h" +#include "protrusions.h" #include "shadows.h" -#include "snow.h" - -#include "experimental.h" +#include "transparency.h" namespace Inkscape { namespace Extension { @@ -30,36 +30,26 @@ void Filter::filters_all (void ) { // Here come the filters which are coded in C++ in order to present a parameters dialog - DropShadow::init(); - DropGlow::init(); - Snow::init(); /* Experimental custom predefined filters */ - // ABC - CleanEdges::init(); - ColorShift::init(); - DiffuseLight::init(); - Feather::init(); - MatteJelly::init(); - NoiseFill::init(); - Outline::init(); - Roughen::init(); - Silhouette::init(); - SpecularLight::init(); - // Blurs Blur::init(); + CleanEdges::init(); CrossBlur::init(); + Feather::init(); ImageBlur::init(); // Bumps Bump::init(); - + DiffuseLight::init(); + MatteJelly::init(); + SpecularLight::init(); + // Color Brightness::init(); ChannelPaint::init(); - ChannelTransparency::init(); + ColorShift::init(); Colorize::init(); Duochrome::init(); Electrize::init(); @@ -69,16 +59,13 @@ Filter::filters_all (void ) Solarize::init(); Tritone::init(); - // Image - EdgeDetect::init(); - - // Morphology - Crosssmooth::init(); + // Distort + Roughen::init(); - // Shadows and glows - ColorizableDropShadow::init(); + // Image effect + EdgeDetect::init(); - // TDB + // Image paint and draw Chromolitho::init(); CrossEngraving::init(); Drawing::init(); @@ -86,6 +73,23 @@ Filter::filters_all (void ) Posterize::init(); PosterizeBasic::init(); + // Morphology + Crosssmooth::init(); + Outline::init(); + + // Overlays + NoiseFill::init(); + + // Protrusions + Snow::init(); + + // Shadows and glows + ColorizableDropShadow::init(); + + // Fill and transparency + ChannelTransparency::init(); + Silhouette::init(); + // Here come the rest of the filters that are read from SVG files in share/filters and // .config/Inkscape/filters /* This should always be last, don't put stuff below this diff --git a/src/extension/internal/filter/image.h b/src/extension/internal/filter/image.h index bc052bfc0..3f1a33055 100644 --- a/src/extension/internal/filter/image.h +++ b/src/extension/internal/filter/image.h @@ -46,7 +46,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" - "<name>" N_("Edge detect, custom (Image)") "</name>\n" + "<name>" N_("Edge detect") "</name>\n" "<id>org.inkscape.effect.filter.EdgeDetect</id>\n" "<param name=\"type\" gui-text=\"" N_("Detect:") "\" type=\"enum\" >\n" "<_item value=\"all\">" N_("All") "</_item>\n" @@ -59,7 +59,7 @@ public: "<object-type>all</object-type>\n" "<effects-menu>\n" "<submenu name=\"" N_("Filters") "\">\n" - "<submenu name=\"" N_("Experimental") "\"/>\n" + "<submenu name=\"" N_("Image effects") "\"/>\n" "</submenu>\n" "</effects-menu>\n" "<menu-tip>" N_("Detect color edges in object") "</menu-tip>\n" @@ -97,7 +97,7 @@ EdgeDetect::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.2\" width=\"1.2\" y=\"-0.1\" x=\"-0.1\" inkscape:label=\"Edge detect, custom\">\n" + "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1.2\" width=\"1.2\" y=\"-0.1\" x=\"-0.1\" inkscape:label=\"Edge detect\">\n" "<feConvolveMatrix in=\"SourceGraphic\" kernelMatrix=\"%s\" order=\"3 3\" bias=\"%s\" divisor=\"%s\" targetX=\"1\" targetY=\"1\" preserveAlpha=\"true\" result=\"convolve\" />\n" "</filter>\n", matrix.str().c_str(), inverted.str().c_str(), level.str().c_str()); diff --git a/src/extension/internal/filter/morphology.h b/src/extension/internal/filter/morphology.h index 25cef0fca..59c33f586 100644 --- a/src/extension/internal/filter/morphology.h +++ b/src/extension/internal/filter/morphology.h @@ -9,6 +9,7 @@ * * Morphology filters * Cross-smooth + * Outline * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -48,7 +49,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" - "<name>" N_("Cross-smooth, custom (Morphology)") "</name>\n" + "<name>" N_("Cross-smooth") "</name>\n" "<id>org.inkscape.effect.filter.crosssmooth</id>\n" "<param name=\"type\" gui-text=\"" N_("Type:") "\" type=\"enum\">\n" "<_item value=\"edges\">Smooth edges</_item>\n" @@ -59,7 +60,7 @@ public: "<object-type>all</object-type>\n" "<effects-menu>\n" "<submenu name=\"" N_("Filters") "\">\n" - "<submenu name=\"" N_("Experimental") "\"/>\n" + "<submenu name=\"" N_("Morphology") "\"/>\n" "</submenu>\n" "</effects-menu>\n" "<menu-tip>" N_("Smooth edges and angles of shapes") "</menu-tip>\n" @@ -87,7 +88,7 @@ Crosssmooth::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=\"Cross-smooth, custom\">\n" + "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Cross-smooth\">\n" "<feGaussianBlur stdDeviation=\"%s\" result=\"blur\" />\n" "<feComposite in=\"%s\" in2=\"blur\" operator=\"atop\" result=\"composite1\" />\n" "<feComposite in2=\"composite1\" operator=\"in\" result=\"composite2\" />\n" @@ -98,6 +99,97 @@ Crosssmooth::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Crosssmooth filter */ +/** + \brief Custom predefined Outline filter. + + Adds a colorizable outline + + Filter's parameters: + * Width (0.01->50., default 5) -> blur1 (stdDeviation) + * Melt (0.01->50., default 2) -> blur2 (stdDeviation) + * Dilatation (1.->50., default 8) -> color2 (n-1th value) + * Erosion (0.->50., default 5) -> color2 (nth value 0->-50) + * Color (guint, default 156,102,102,255) -> flood (flood-color, flood-opacity) + * Blend (enum, default Normal) -> blend (mode) +*/ + +class Outline : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + Outline ( ) : Filter() { }; + virtual ~Outline ( ) { 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_("Outline") "</name>\n" + "<id>org.inkscape.effect.filter.Outline</id>\n" + "<param name=\"tab\" type=\"notebook\">\n" + "<page name=\"optionstab\" _gui-text=\"Options\">\n" + "<param name=\"width\" gui-text=\"" N_("Width:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"50.00\">5</param>\n" + "<param name=\"melt\" gui-text=\"" N_("Melt:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"50.00\">2</param>\n" + "<param name=\"dilat\" gui-text=\"" N_("Dilatation:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"50\">8</param>\n" + "<param name=\"erosion\" gui-text=\"" N_("Erosion:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"50\">5</param>\n" + "</page>\n" + "<page name=\"co11tab\" _gui-text=\"Color\">\n" + "<param name=\"color\" gui-text=\"" N_("Color") "\" type=\"color\">1029214207</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_("Morphology") "\"/>\n" + "</submenu>\n" + "</effects-menu>\n" + "<menu-tip>" N_("Adds a colorizable outline") "</menu-tip>\n" + "</effect>\n" + "</inkscape-extension>\n", new Outline()); + }; + +}; + +gchar const * +Outline::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream width; + std::ostringstream melt; + std::ostringstream dilat; + std::ostringstream erosion; + std::ostringstream r; + std::ostringstream g; + std::ostringstream b; + std::ostringstream a; + std::ostringstream blend; + + width << ext->get_param_float("width"); + melt << ext->get_param_float("melt"); + dilat << ext->get_param_float("dilat"); + erosion << (- ext->get_param_float("erosion")); + guint32 color = ext->get_param_color("color"); + r << ((color >> 24) & 0xff); + g << ((color >> 16) & 0xff); + b << ((color >> 8) & 0xff); + a << (color & 0xff) / 255.0F; + + _filter = g_strdup_printf( + "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1.3\" width=\"1.3\" y=\"-0.15\" x=\"-0.15\" inkscape:label=\"Outline\">\n" + "<feGaussianBlur in=\"SourceAlpha\" stdDeviation=\"%s\" result=\"blur1\" />\n" + "<feColorMatrix result=\"color1\" values=\"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 200 -1 \" />\n" + "<feGaussianBlur in=\"color1\" 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 %s \" result=\"color2\" />\n" + "<feFlood in=\"color2\" result=\"flood\" flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" />\n" + "<feComposite in=\"flood\" in2=\"color2\" operator=\"in\" result=\"composite\" />\n" + "<feBlend in=\"SourceGraphic\" in2=\"composite\" mode=\"normal\" blend=\"normal\" />\n" + "</filter>\n", width.str().c_str(), melt.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str()); + + return _filter; +}; /* Outline filter */ + }; /* namespace Filter */ }; /* namespace Internal */ }; /* namespace Extension */ diff --git a/src/extension/internal/filter/overlays.h b/src/extension/internal/filter/overlays.h new file mode 100644 index 000000000..4c59b553b --- /dev/null +++ b/src/extension/internal/filter/overlays.h @@ -0,0 +1,147 @@ +#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_OVERLAYS_H__ +#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_OVERLAYS_H__ +/* Change the 'OVERLAYS' above to be your file name */ + +/* + * Copyright (C) 2011 Authors: + * Ivan Louette (filters) + * Nicolas Dufour (UI) <nicoduf@yahoo.fr> + * + * Overlays filters + * Noise fill + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ +/* ^^^ Change the copyright to be you and your e-mail address ^^^ */ + +#include "filter.h" + +#include "extension/internal/clear-n_.h" +#include "extension/system.h" +#include "extension/extension.h" + +namespace Inkscape { +namespace Extension { +namespace Internal { +namespace Filter { + +/** + \brief Custom predefined Noise fill filter. + + Basic noise fill and transparency texture + + Filter's parameters: + * Turbulence type (enum, default fractalNoise else turbulence) -> turbulence (type) + * Horizontal frequency (*1000) (0.01->10000., default 20) -> turbulence (baseFrequency [/1000]) + * Vertical frequency (*1000) (0.01->10000., default 40) -> turbulence (baseFrequency [/1000]) + * Complexity (1->5, default 5) -> turbulence (numOctaves) + * Variation (1->360, default 1) -> turbulence (seed) + * Dilatation (1.->50., default 3) -> color (n-1th value) + * Erosion (0.->50., default 1) -> color (nth value 0->-50) + * Color (guint, default 148,115,39,255) -> flood (flood-color, flood-opacity) + * Inverted (boolean, default false) -> composite1 (operator, true="in", false="out") +*/ + +class NoiseFill : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + NoiseFill ( ) : Filter() { }; + virtual ~NoiseFill ( ) { 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_("Noise fill") "</name>\n" + "<id>org.inkscape.effect.filter.NoiseFill</id>\n" + "<param name=\"tab\" type=\"notebook\">\n" + "<page name=\"optionstab\" _gui-text=\"Options\">\n" + "<param name=\"type\" gui-text=\"" N_("Turbulence type:") "\" 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=\"2\" min=\"0.01\" max=\"10000.00\">20</param>\n" + "<param name=\"vfreq\" gui-text=\"" N_("Vertical frequency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10000.00\">40</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=\"dilat\" gui-text=\"" N_("Dilatation:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"50\">3</param>\n" + "<param name=\"erosion\" gui-text=\"" N_("Erosion:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"50\">1</param>\n" + "<param name=\"inverted\" gui-text=\"" N_("Inverted") "\" type=\"boolean\" >false</param>\n" + "</page>\n" + "<page name=\"co11tab\" _gui-text=\"Noise color\">\n" + "<param name=\"color\" gui-text=\"" N_("Color") "\" type=\"color\">354957823</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_("Overlays") "\"/>\n" + "</submenu>\n" + "</effects-menu>\n" + "<menu-tip>" N_("Basic noise fill and transparency texture") "</menu-tip>\n" + "</effect>\n" + "</inkscape-extension>\n", new NoiseFill()); + }; + +}; + +gchar const * +NoiseFill::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream type; + std::ostringstream hfreq; + std::ostringstream vfreq; + std::ostringstream complexity; + std::ostringstream variation; + std::ostringstream dilat; + std::ostringstream erosion; + std::ostringstream r; + std::ostringstream g; + std::ostringstream b; + std::ostringstream a; + std::ostringstream inverted; + + type << ext->get_param_enum("type"); + hfreq << (ext->get_param_float("hfreq") / 1000); + vfreq << (ext->get_param_float("vfreq") / 1000); + complexity << ext->get_param_int("complexity"); + variation << ext->get_param_int("variation"); + dilat << ext->get_param_float("dilat"); + erosion << (- ext->get_param_float("erosion")); + guint32 color = ext->get_param_color("color"); + r << ((color >> 24) & 0xff); + g << ((color >> 16) & 0xff); + b << ((color >> 8) & 0xff); + a << (color & 0xff) / 255.0F; + if (ext->get_param_bool("inverted")) + inverted << "out"; + else + inverted << "in"; + + _filter = g_strdup_printf( + "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Noise fill\">\n" + "<feTurbulence type=\"%s\" baseFrequency=\"%s %s\" numOctaves=\"%s\" seed=\"%s\" result=\"turbulence\"/>\n" + "<feComposite in=\"SourceGraphic\" in2=\"turbulence\" operator=\"%s\" result=\"composite1\" />\n" + "<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 %s %s \" result=\"color\" />\n" + "<feFlood in=\"color\" flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood\" />\n" + "<feMerge result=\"merge\">\n" + "<feMergeNode in=\"flood\" />\n" + "<feMergeNode in=\"color\" />\n" + "</feMerge>\n" + "<feComposite in2=\"SourceGraphic\" operator=\"in\" result=\"composite2\" />\n" + "</filter>\n", type.str().c_str(), hfreq.str().c_str(), vfreq.str().c_str(), complexity.str().c_str(), variation.str().c_str(), inverted.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str()); + + return _filter; +}; /* NoiseFill filter */ + +}; /* namespace Filter */ +}; /* namespace Internal */ +}; /* namespace Extension */ +}; /* namespace Inkscape */ + +/* Change the 'OVERLAYS' below to be your file name */ +#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_OVERLAYS_H__ */ diff --git a/src/extension/internal/filter/experimental.h b/src/extension/internal/filter/paint.h index 2032cb513..7a1cc6046 100755..100644 --- a/src/extension/internal/filter/experimental.h +++ b/src/extension/internal/filter/paint.h @@ -1,13 +1,13 @@ -#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_EXPERIMENTAL_H__ -#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_EXPERIMENTAL_H__ -/* Change the 'EXPERIMENTAL' above to be your file name */ +#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_PAINT_H__ +#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_PAINT_H__ +/* Change the 'PAINT' above to be your file name */ /* * Copyright (C) 2011 Authors: * Ivan Louette (filters) * Nicolas Dufour (UI) <nicoduf@yahoo.fr> * - * Experimental filters (no assigned menu) + * Image paint and draw filters * Chromolitho * Cross engraving * Drawing @@ -66,7 +66,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" - "<name>" N_("Chromolitho, custom") "</name>\n" + "<name>" N_("Chromolitho") "</name>\n" "<id>org.inkscape.effect.filter.Chromolitho</id>\n" "<param name=\"tab\" type=\"notebook\">\n" "<page name=\"optionstab\" _gui-text=\"Options\">\n" @@ -108,7 +108,7 @@ public: "<object-type>all</object-type>\n" "<effects-menu>\n" "<submenu name=\"" N_("Filters") "\">\n" - "<submenu name=\"" N_("Experimental") "\"/>\n" + "<submenu name=\"" N_("Image Paint and Draw") "\"/>\n" "</submenu>\n" "</effects-menu>\n" "<menu-tip>" N_("Chromo effect with customizable edge drawing and graininess") "</menu-tip>\n" @@ -181,7 +181,7 @@ Chromolitho::get_filter_text (Inkscape::Extension::Extension * ext) graincol << "0"; _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=\"Chromolitho, custom\">\n" + "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Chromolitho\">\n" "<feComposite stdDeviation=\"1\" in=\"SourceGraphic\" in2=\"SourceGraphic\" operator=\"arithmetic\" k1=\"%s\" k2=\"1\" result=\"composite1\" />\n" "<feConvolveMatrix in=\"composite1\" kernelMatrix=\"0 250 0 250 %s 250 0 250 0 \" order=\"3 3\" stdDeviation=\"1\" result=\"convolve1\" />\n" "<feBlend in=\"%s\" in2=\"composite1\" mode=\"%s\" blend=\"normal\" stdDeviation=\"1\" result=\"blend1\" />\n" @@ -228,7 +228,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" - "<name>" N_("Cross engraving, custom") "</name>\n" + "<name>" N_("Cross engraving") "</name>\n" "<id>org.inkscape.effect.filter.CrossEngraving</id>\n" "<param name=\"clean\" gui-text=\"" N_("Clean-up:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"500\">30</param>\n" "<param name=\"dilat\" gui-text=\"" N_("Dilatation:") "\" type=\"float\" appearance=\"full\" min=\"1\" max=\"50\">1</param>\n" @@ -240,7 +240,7 @@ public: "<object-type>all</object-type>\n" "<effects-menu>\n" "<submenu name=\"" N_("Filters") "\">\n" - "<submenu name=\"" N_("Experimental") "\"/>\n" + "<submenu name=\"" N_("Image Paint and Draw") "\"/>\n" "</submenu>\n" "</effects-menu>\n" "<menu-tip>" N_("Convert image to an engraving made of vertical and horizontal lines") "</menu-tip>\n" @@ -272,7 +272,7 @@ CrossEngraving::get_filter_text (Inkscape::Extension::Extension * ext) trans << "blend"; _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 engraving, custom\">\n" + "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Cross engraving\">\n" "<feConvolveMatrix in=\"SourceGraphic\" targetY=\"1\" targetX=\"1\" kernelMatrix=\"0 250 0 250 %s 250 0 250 0 \" order=\"3 3\" result=\"convolve\" />\n" "<feComposite in=\"convolve\" in2=\"convolve\" k1=\"1\" k2=\"1\" operator=\"arithmetic\" result=\"composite1\" />\n" "<feColorMatrix in=\"composite1\" 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=\"color1\" />\n" @@ -327,7 +327,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" - "<name>" N_("Drawing, custom") "</name>\n" + "<name>" N_("Drawing") "</name>\n" "<id>org.inkscape.effect.filter.Drawing</id>\n" "<param name=\"tab\" type=\"notebook\">\n" "<page name=\"optionstab\" _gui-text=\"Options\">\n" @@ -359,7 +359,7 @@ public: "<object-type>all</object-type>\n" "<effects-menu>\n" "<submenu name=\"" N_("Filters") "\">\n" - "<submenu name=\"" N_("Experimental") "\"/>\n" + "<submenu name=\"" N_("Image Paint and Draw") "\"/>\n" "</submenu>\n" "</effects-menu>\n" "<menu-tip>" N_("Convert images to duochrome drawings") "</menu-tip>\n" @@ -432,7 +432,7 @@ Drawing::get_filter_text (Inkscape::Extension::Extension * ext) ios << "flood2"; _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=\"Drawing, custom\">\n" + "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Drawing\">\n" "<feGaussianBlur in=\"SourceGraphic\" stdDeviation=\"%s\" result=\"blur1\" />\n" "<feConvolveMatrix in=\"blur1\" targetX=\"1\" targetY=\"1\" order=\"3 3\" kernelMatrix=\"0 250 0 250 %s 250 0 250 0 \" result=\"convolve1\" />\n" "<feComposite in=\"convolve1\" in2=\"convolve1\" k1=\"1\" k2=\"1\" k4=\"%s\" operator=\"arithmetic\" stdDeviation=\"1\" result=\"composite1\" />\n" @@ -494,7 +494,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" - "<name>" N_("Neon draw, custom") "</name>\n" + "<name>" N_("Neon draw") "</name>\n" "<id>org.inkscape.effect.filter.NeonDraw</id>\n" "<param name=\"type\" gui-text=\"" N_("Line type:") "\" type=\"enum\">\n" "<_item value=\"table\">Smoothed</_item>\n" @@ -513,7 +513,7 @@ public: "<object-type>all</object-type>\n" "<effects-menu>\n" "<submenu name=\"" N_("Filters") "\">\n" - "<submenu name=\"" N_("Experimental") "\"/>\n" + "<submenu name=\"" N_("Image Paint and Draw") "\"/>\n" "</submenu>\n" "</effects-menu>\n" "<menu-tip>" N_("Posterize and draw smooth lines around color shapes") "</menu-tip>\n" @@ -549,7 +549,7 @@ NeonDraw::get_filter_text (Inkscape::Extension::Extension * ext) 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, custom\">\n" + "<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" "<feBlend blend=\"normal\" mode=\"%s\" result=\"blend\" />\n" "<feGaussianBlur in=\"blend\" stdDeviation=\"%s\" result=\"blur1\" />\n" "<feComponentTransfer result=\"component1\">\n" @@ -599,7 +599,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" - "<name>" N_("Poster paint, custom") "</name>\n" + "<name>" N_("Poster paint") "</name>\n" "<id>org.inkscape.effect.filter.Posterize</id>\n" "<param name=\"type\" gui-text=\"" N_("Effect type:") "\" type=\"enum\">\n" "<_item value=\"normal\">Normal</_item>\n" @@ -626,7 +626,7 @@ public: "<object-type>all</object-type>\n" "<effects-menu>\n" "<submenu name=\"" N_("Filters") "\">\n" - "<submenu name=\"" N_("Experimental") "\"/>\n" + "<submenu name=\"" N_("Image Paint and Draw") "\"/>\n" "</submenu>\n" "</effects-menu>\n" "<menu-tip>" N_("Poster and painting effects") "</menu-tip>\n" @@ -684,7 +684,7 @@ Posterize::get_filter_text (Inkscape::Extension::Extension * ext) antialias << "0.01"; _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=\"Poster paint, custom\">\n" + "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Poster paint\">\n" "<feComposite operator=\"arithmetic\" k2=\"1\" result=\"composite1\" />\n" "<feGaussianBlur stdDeviation=\"%s\" result=\"blur1\" />\n" "<feGaussianBlur in=\"composite1\" stdDeviation=\"%s\" result=\"blur2\" />\n" @@ -723,7 +723,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" - "<name>" N_("Posterize basic, custom") "</name>\n" + "<name>" N_("Posterize basic") "</name>\n" "<id>org.inkscape.effect.filter.PosterizeBasic</id>\n" "<param name=\"levels\" gui-text=\"" N_("Levels:") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"20\">5</param>\n" "<param name=\"blur\" gui-text=\"" N_("Simplify:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">4.0</param>\n" @@ -731,7 +731,7 @@ public: "<object-type>all</object-type>\n" "<effects-menu>\n" "<submenu name=\"" N_("Filters") "\">\n" - "<submenu name=\"" N_("Experimental") "\"/>\n" + "<submenu name=\"" N_("Image Paint and Draw") "\"/>\n" "</submenu>\n" "</effects-menu>\n" "<menu-tip>" N_("Simple posterizing effect") "</menu-tip>\n" @@ -760,7 +760,7 @@ PosterizeBasic::get_filter_text (Inkscape::Extension::Extension * ext) transf << " 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=\"Posterize basic, custom\">\n" + "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Posterize basic\">\n" "<feGaussianBlur stdDeviation=\"%s\" result=\"blur1\" />\n" "<feComponentTransfer stdDeviation=\"2\" in=\"blur1\" result=\"component1\">\n" "<feFuncR type=\"discrete\" tableValues=\"%s\" />\n" @@ -778,5 +778,5 @@ PosterizeBasic::get_filter_text (Inkscape::Extension::Extension * ext) }; /* namespace Extension */ }; /* namespace Inkscape */ -/* Change the 'EXPERIMENTAL' below to be your file name */ -#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_EXPERIMENTAL_H__ */ +/* Change the 'PAINT' below to be your file name */ +#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_PAINT_H__ */ diff --git a/src/extension/internal/filter/snow.h b/src/extension/internal/filter/protrusions.h index 7a15f9efa..9103bdc11 100644 --- a/src/extension/internal/filter/snow.h +++ b/src/extension/internal/filter/protrusions.h @@ -1,10 +1,16 @@ -#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_SNOW_H__ -#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_SNOW_H__ -/* Change the 'SNOW' above to be your file name */ +#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_PROTRUSIONS_H__ +#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_PROTRUSIONS_H__ +/* Change the 'PROTRUSIONS' above to be your file name */ /* * Copyright (C) 2008 Authors: * Ted Gould <ted@gould.cx> + * Copyright (C) 2011 Authors: + * Ivan Louette (filters) + * Nicolas Dufour (UI) <nicoduf@yahoo.fr> + * + * Protrusion filters + * Snow * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -12,11 +18,21 @@ #include "filter.h" +#include "extension/internal/clear-n_.h" +#include "extension/system.h" +#include "extension/extension.h" + namespace Inkscape { namespace Extension { namespace Internal { namespace Filter { + +/** + \brief Custom predefined Snow filter. + + Snow has fallen on object. +*/ class Snow : public Inkscape::Extension::Internal::Filter::Filter { protected: virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); @@ -71,12 +87,13 @@ Snow::get_filter_text (Inkscape::Extension::Extension * ext) "</filter>\n", drift.str().c_str()); return _filter; -}; +}; /* Snow filter */ + }; /* namespace Filter */ }; /* namespace Internal */ }; /* namespace Extension */ }; /* namespace Inkscape */ -/* Change the 'SNOW' below to be your file name */ -#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_SNOW_H__ */ +/* Change the 'PROTRUSIONS' below to be your file name */ +#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_PROTRUSIONS_H__ */ diff --git a/src/extension/internal/filter/shadows.h b/src/extension/internal/filter/shadows.h index 2339373c1..49f1003cc 100644 --- a/src/extension/internal/filter/shadows.h +++ b/src/extension/internal/filter/shadows.h @@ -53,7 +53,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" - "<name>" N_("Drop shadow, custom (Shadows and Glows)") "</name>\n" + "<name>" N_("Drop shadow") "</name>\n" "<id>org.inkscape.effect.filter.ColorDropShadow</id>\n" "<param name=\"tab\" type=\"notebook\">\n" "<page name=\"optionstab\" _gui-text=\"" N_("Options") "\">\n" @@ -76,7 +76,7 @@ public: "<object-type>all</object-type>\n" "<effects-menu>\n" "<submenu name=\"" N_("Filters") "\">\n" - "<submenu name=\"" N_("Experimental") "\"/>\n" + "<submenu name=\"" N_("Shadows and Glows") "\"/>\n" "</submenu>\n" "</effects-menu>\n" "<menu-tip>" N_("Colorizable Drop shadow") "</menu-tip>\n" @@ -158,7 +158,7 @@ ColorizableDropShadow::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.2\" width=\"1.2\" y=\"-0.1\" x=\"-0.1\" inkscape:label=\"Drop shadow, custom\">\n" + "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1.2\" width=\"1.2\" y=\"-0.1\" x=\"-0.1\" inkscape:label=\"Drop shadow\">\n" "<feFlood flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood\" />\n" "<feComposite in=\"%s\" in2=\"%s\" operator=\"%s\" result=\"composite1\" />\n" "<feGaussianBlur in=\"composite1\" stdDeviation=\"%s\" result=\"blur\" />\n" @@ -170,7 +170,7 @@ ColorizableDropShadow::get_filter_text (Inkscape::Extension::Extension * ext) comp2in1.str().c_str(), comp2in2.str().c_str(), comp2op.str().c_str()); return _filter; -}; +}; /* Drop shadow filter */ }; /* namespace Filter */ }; /* namespace Internal */ diff --git a/src/extension/internal/filter/transparency.h b/src/extension/internal/filter/transparency.h new file mode 100644 index 000000000..c47df89df --- /dev/null +++ b/src/extension/internal/filter/transparency.h @@ -0,0 +1,192 @@ +#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_TRANSPARENCY_H__ +#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_TRANSPARENCY_H__ +/* Change the 'TRANSPARENCY' above to be your file name */ + +/* + * Copyright (C) 2011 Authors: + * Ivan Louette (filters) + * Nicolas Dufour (UI) <nicoduf@yahoo.fr> + * + * Fill and transparency filters + * Channel transparency + * Silhouette + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ +/* ^^^ Change the copyright to be you and your e-mail address ^^^ */ + +#include "filter.h" + +#include "extension/internal/clear-n_.h" +#include "extension/system.h" +#include "extension/extension.h" + +namespace Inkscape { +namespace Extension { +namespace Internal { +namespace Filter { + +/** + \brief Custom predefined Channel transparency filter. + + Channel transparency filter. + + Filter's parameters: + * Saturation (0.->1., default 1.) -> colormatrix1 (values) + * Red (-10.->10., default -1.) -> colormatrix2 (values) + * Green (-10.->10., default 0.5) -> colormatrix2 (values) + * Blue (-10.->10., default 0.5) -> colormatrix2 (values) + * Alpha (-10.->10., default 1.) -> colormatrix2 (values) + * Flood colors (guint, default 16777215) -> flood (flood-opacity, flood-color) + * Inverted (boolean, default false) -> composite1 (operator, true='in', false='out') + + Matrix: + 1 0 0 0 0 + 0 1 0 0 0 + 0 0 1 0 0 + R G B A 0 +*/ +class ChannelTransparency : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + ChannelTransparency ( ) : Filter() { }; + virtual ~ChannelTransparency ( ) { 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_("Channel transparency") "</name>\n" + "<id>org.inkscape.effect.filter.ChannelTransparency</id>\n" + "<param name=\"red\" gui-text=\"" N_("Red:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.00\" max=\"10.00\">-1</param>\n" + "<param name=\"green\" gui-text=\"" N_("Green:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.00\" max=\"10.00\">0.5</param>\n" + "<param name=\"blue\" gui-text=\"" N_("Blue:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.00\" max=\"10.00\">0.5</param>\n" + "<param name=\"alpha\" gui-text=\"" N_("Alpha:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1.\">1</param>\n" + "<param name=\"invert\" gui-text=\"" N_("Inverted") "\" type=\"boolean\">false</param>\n" + "<effect>\n" + "<object-type>all</object-type>\n" + "<effects-menu>\n" + "<submenu name=\"" N_("Filters") "\">\n" + "<submenu name=\"" N_("Fill and Transparency") "\"/>\n" + "</submenu>\n" + "</effects-menu>\n" + "<menu-tip>" N_("Replace RGB with transparency") "</menu-tip>\n" + "</effect>\n" + "</inkscape-extension>\n", new ChannelTransparency()); + }; +}; + +gchar const * +ChannelTransparency::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream red; + std::ostringstream green; + std::ostringstream blue; + std::ostringstream alpha; + std::ostringstream invert; + + red << ext->get_param_float("red"); + green << ext->get_param_float("green"); + blue << ext->get_param_float("blue"); + alpha << ext->get_param_float("alpha"); + + if (!ext->get_param_bool("invert")) { + invert << "in"; + } else { + invert << "xor"; + } + + _filter = g_strdup_printf( + "<filter inkscape:label=\"Channel transparency\" color-interpolation-filters=\"sRGB\" x=\"0\" y=\"0\" width=\"1\" height=\"1\">\n" + "<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 %s %s %s %s 0 \" in=\"SourceGraphic\" result=\"colormatrix\" />\n" + "<feComposite in=\"colormatrix\" in2=\"SourceGraphic\" operator=\"%s\" result=\"composite1\" />\n" + "</filter>\n", red.str().c_str(), green.str().c_str(), blue.str().c_str(), alpha.str().c_str(), + invert.str().c_str()); + + return _filter; +}; /* Channel transparency filter */ + +/** + \brief Custom predefined Silhouette filter. + + Repaint anything visible monochrome + + Filter's parameters: + * Blur (0.01->50., default 0.01) -> blur (stdDeviation) + * Cutout (boolean, default False) -> composite (false=in, true=out) + * Color (guint, default 0,0,0,255) -> flood (flood-color, flood-opacity) +*/ + +class Silhouette : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + Silhouette ( ) : Filter() { }; + virtual ~Silhouette ( ) { 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_("Silhouette") "</name>\n" + "<id>org.inkscape.effect.filter.Silhouette</id>\n" + "<param name=\"blur\" gui-text=\"" N_("Blur:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"50.00\">0.01</param>\n" + "<param name=\"cutout\" gui-text=\"" N_("Cutout") "\" type=\"boolean\">false</param>\n" + "<param name=\"color\" gui-text=\"" N_("Color") "\" type=\"color\">255</param>\n" + "<effect>\n" + "<object-type>all</object-type>\n" + "<effects-menu>\n" + "<submenu name=\"" N_("Filters") "\">\n" + "<submenu name=\"" N_("Fill and Transparency") "\"/>\n" + "</submenu>\n" + "</effects-menu>\n" + "<menu-tip>" N_("Repaint anything visible monochrome") "</menu-tip>\n" + "</effect>\n" + "</inkscape-extension>\n", new Silhouette()); + }; + +}; + +gchar const * +Silhouette::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream a; + std::ostringstream r; + std::ostringstream g; + std::ostringstream b; + std::ostringstream cutout; + std::ostringstream blur; + + guint32 color = ext->get_param_color("color"); + r << ((color >> 24) & 0xff); + g << ((color >> 16) & 0xff); + b << ((color >> 8) & 0xff); + a << (color & 0xff) / 255.0F; + if (ext->get_param_bool("cutout")) + cutout << "out"; + else + cutout << "in"; + blur << ext->get_param_float("blur"); + + _filter = g_strdup_printf( + "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Silhouette\">\n" + "<feFlood in=\"SourceGraphic\" flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood\" />\n" + "<feComposite in=\"flood\" in2=\"SourceGraphic\" operator=\"%s\" result=\"composite\" />\n" + "<feGaussianBlur stdDeviation=\"%s\" />\n" + "</filter>\n", a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), cutout.str().c_str(), blur.str().c_str()); + + return _filter; +}; /* Silhouette filter */ + +}; /* namespace Filter */ +}; /* namespace Internal */ +}; /* namespace Extension */ +}; /* namespace Inkscape */ + +/* Change the 'TRANSPARENCY' below to be your file name */ +#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_TRANSPARENCY_H__ */ |
