diff options
| author | Nicolas Dufour <nicoduf@yahoo.fr> | 2011-08-20 19:26:29 +0000 |
|---|---|---|
| committer | JazzyNico <nicoduf@yahoo.fr> | 2011-08-20 19:26:29 +0000 |
| commit | 369d232bba58127f1962415ab437614a61980196 (patch) | |
| tree | ba97b1a0f59084a575877a54e295fff3d62392ce /src | |
| parent | Filters. Fix for bug #713064 (Filter Effect Turbulence Base frequency limited... (diff) | |
| download | inkscape-369d232bba58127f1962415ab437614a61980196.tar.gz inkscape-369d232bba58127f1962415ab437614a61980196.zip | |
Filters. More filters clean-up.
Filters. New Outline filter (rewrite).
Filters. Replace the default blend="normal" attribute with mode="normal" for the feBlend primitive.
(bzr r10558)
Diffstat (limited to 'src')
| -rw-r--r-- | src/extension/internal/filter/bevels.h | 282 | ||||
| -rw-r--r-- | src/extension/internal/filter/bumps.h | 249 | ||||
| -rwxr-xr-x | src/extension/internal/filter/filter-all.cpp | 9 | ||||
| -rw-r--r-- | src/extension/internal/filter/morphology.h | 127 | ||||
| -rw-r--r-- | src/filter-chemistry.cpp | 2 |
5 files changed, 390 insertions, 279 deletions
diff --git a/src/extension/internal/filter/bevels.h b/src/extension/internal/filter/bevels.h new file mode 100644 index 000000000..6fc73e58a --- /dev/null +++ b/src/extension/internal/filter/bevels.h @@ -0,0 +1,282 @@ +#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_BEVELS_H__ +#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_BEVELS_H__ +/* Change the 'BEVELS' above to be your file name */ + +/* + * Copyright (C) 2011 Authors: + * Ivan Louette (filters) + * Nicolas Dufour (UI) <nicoduf@yahoo.fr> + * + * Bevel filters + * Diffuse light + * Matte jelly + * 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 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_("Bevels") "\"/>\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\" style=\"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_("Bevels") "\"/>\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\" style=\"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_("Bevels") "\"/>\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\" style=\"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 */ +}; /* namespace Extension */ +}; /* namespace Inkscape */ + +/* Change the 'BEVELS' below to be your file name */ +#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_BEVELS_H__ */ diff --git a/src/extension/internal/filter/bumps.h b/src/extension/internal/filter/bumps.h index bb2bfd8a8..f002c8b37 100644 --- a/src/extension/internal/filter/bumps.h +++ b/src/extension/internal/filter/bumps.h @@ -9,9 +9,6 @@ * * Bump filters * Bump - * Diffuse light - * Matte jelly - * Specular light * Wax bump * * Released under GNU GPL, read the file 'COPYING' for more information @@ -269,252 +266,6 @@ Bump::get_filter_text (Inkscape::Extension::Extension * ext) }; /* 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\" style=\"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\" style=\"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\" style=\"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 */ - -/** \brief Custom predefined Wax Bump filter. Turns an image to jelly diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp index 7dd35b055..17c22c0cb 100755 --- a/src/extension/internal/filter/filter-all.cpp +++ b/src/extension/internal/filter/filter-all.cpp @@ -8,6 +8,7 @@ #include "filter.h" /* Put your filter here */ +#include "bevels.h" #include "blurs.h" #include "bumps.h" #include "color.h" @@ -34,6 +35,11 @@ Filter::filters_all (void ) /* Experimental custom predefined filters */ + // Bevels + DiffuseLight::init(); + MatteJelly::init(); + SpecularLight::init(); + // Blurs Blur::init(); CleanEdges::init(); @@ -43,9 +49,6 @@ Filter::filters_all (void ) // Bumps Bump::init(); - DiffuseLight::init(); - MatteJelly::init(); - SpecularLight::init(); WaxBump::init(); // Color diff --git a/src/extension/internal/filter/morphology.h b/src/extension/internal/filter/morphology.h index e51eb5a0b..4b69f564b 100644 --- a/src/extension/internal/filter/morphology.h +++ b/src/extension/internal/filter/morphology.h @@ -105,12 +105,23 @@ Crosssmooth::get_filter_text (Inkscape::Extension::Extension * ext) 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) + * Stroke type (enum, default single) + * single -> composite4 (in="composite3"), composite2 (operator="atop") + * double -> composite4 (in="SourceGraphic"), composite2 (operator="xor") + * Stroke position (enum, default inside) + * inside -> composite1 (operator="out", in="SourceGraphic", in2="blur1") + * outside -> composite1 (operator="out", in="blur1", in2="SourceGraphic") + * overlayed -> composite1 (operator="xor", in="blur1", in2="SourceGraphic") + * Width 1(0.01->20., default 4) -> blur1 (stdDeviation) + * Width 2 (0.01->20., default 0.5) -> blur2 (stdDeviation) + * Dilatation 1 (1.->100., default 100) -> colormatrix1 (n-1th value) + * Erosion 1 (0.->100., default 1) -> colormatrix1 (nth value 0->-100) + * Dilatation 2 (1.->100., default 50) -> colormatrix2 (n-1th value) + * Erosion 2 (0.->100., default 5) -> colormatrix2 (nth value 0->-100) + * Color (guint, default 200,55,55,255) -> flood (flood-color, flood-opacity) + * Fill opacity (0.->1., default 1) -> composite5 (k2) + * Stroke opacity (0.->1., default 1) -> composite5 (k3) + */ class Outline : public Inkscape::Extension::Internal::Filter::Filter { @@ -128,13 +139,26 @@ public: "<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" + "<param name=\"type\" gui-text=\"" N_("Type:") "\" type=\"enum\">\n" + "<_item value=\"single\">" N_("Single") "</_item>\n" + "<_item value=\"double\">" N_("Double") "</_item>\n" + "</param>\n" + "<param name=\"position\" gui-text=\"" N_("Position:") "\" type=\"enum\">\n" + "<_item value=\"inside\">" N_("Inside") "</_item>\n" + "<_item value=\"outside\">" N_("Outside") "</_item>\n" + "<_item value=\"overlayed\">" N_("Overlayed") "</_item>\n" + "</param>\n" + "<param name=\"width1\" gui-text=\"" N_("Width 1:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">4</param>\n" + "<param name=\"width2\" gui-text=\"" N_("Width 2:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">0.5</param>\n" + "<param name=\"dilat1\" gui-text=\"" N_("Dilatation 1:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"100\">100</param>\n" + "<param name=\"erosion1\" gui-text=\"" N_("Erosion 1:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"100\">1</param>\n" + "<param name=\"dilat2\" gui-text=\"" N_("Dilatation 2:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"100\">50</param>\n" + "<param name=\"erosion2\" gui-text=\"" N_("Erosion 2:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"100\">5</param>\n" "</page>\n" "<page name=\"co11tab\" _gui-text=\"Color\">\n" "<param name=\"color\" gui-text=\"" N_("Color") "\" type=\"color\">1029214207</param>\n" + "<param name=\"fopacity\" gui-text=\"" N_("Fill opacity:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1\">1</param>\n" + "<param name=\"sopacity\" gui-text=\"" N_("Stroke opacity:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1\">1</param>\n" "</page>\n" "</param>\n" "<effect>\n" @@ -156,36 +180,87 @@ 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 width1; + std::ostringstream width2; + std::ostringstream dilat1; + std::ostringstream erosion1; + std::ostringstream dilat2; + std::ostringstream erosion2; std::ostringstream r; std::ostringstream g; std::ostringstream b; std::ostringstream a; - std::ostringstream blend; + std::ostringstream fopacity; + std::ostringstream sopacity; + std::ostringstream c4in; + std::ostringstream c4op; + std::ostringstream c1in; + std::ostringstream c1in2; + std::ostringstream c1op; + + width1 << ext->get_param_float("width1"); + width2 << ext->get_param_float("width2"); + dilat1 << ext->get_param_float("dilat1"); + erosion1 << (- ext->get_param_float("erosion1")); + dilat2 << ext->get_param_float("dilat2"); + erosion2 << (- ext->get_param_float("erosion2")); - 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; + fopacity << ext->get_param_float("fopacity"); + sopacity << ext->get_param_float("sopacity"); + + const gchar *type = ext->get_param_enum("type"); + if((g_ascii_strcasecmp("single", type) == 0)) { + // Single + c4in << "composite3"; + c4op << "atop"; + } else { + // Double + c4in << "SourceGraphic"; + c4op << "xor"; + } + + const gchar *position = ext->get_param_enum("position"); + if((g_ascii_strcasecmp("inside", position) == 0)) { + // Indide + c1in << "SourceGraphic3"; + c1in2 << "blur1"; + c1op << "out"; + } else if((g_ascii_strcasecmp("outside", position) == 0)) { + // Outside + c1in << "blur1"; + c1in2 << "SourceGraphic"; + c1op << "out"; + } else { + // Overlayed + c1in << "blur1"; + c1in2 << "SourceGraphic"; + c1op << "xor"; + } + _filter = g_strdup_printf( - "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" height=\"1.3\" width=\"1.3\" y=\"-0.15\" x=\"-0.15\" inkscape:label=\"Outline\">\n" + "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" height=\"1.4\" width=\"1.4\" y=\"-0.2\" x=\"-0.2\" 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" + "<feComposite in=\"%s\" in2=\"%s\" 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=\"colormatrix1\" />\n" + "<feGaussianBlur stdDeviation=\"%s\" result=\"blur2\" />\n" + "<feComposite in2=\"blur2\" operator=\"over\" result=\"composite2\" />\n" + "<feColorMatrix in=\"composite2\" values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 %s %s \" result=\"colormatrix2\" />\n" "<feFlood flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood\" />\n" - "<feComposite in=\"flood\" in2=\"color2\" operator=\"in\" result=\"composite\" />\n" - "<feBlend in=\"SourceGraphic\" in2=\"composite\" mode=\"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()); + "<feComposite in=\"flood\" in2=\"colormatrix2\" k2=\"1\" operator=\"in\" result=\"composite3\" />\n" + "<feComposite in=\"%s\" in2=\"colormatrix2\" operator=\"%s\" result=\"composite4\" />\n" + "<feComposite in=\"composite4\" in2=\"composite3\" k2=\"%s\" k3=\"%s\" operator=\"arithmetic\" result=\"composite5\" />\n" + "</filter>\n", width1.str().c_str(), c1in.str().c_str(), c1in2.str().c_str(), c1op.str().c_str(), + dilat1.str().c_str(), erosion1.str().c_str(), + width2.str().c_str(), dilat2.str().c_str(), erosion2.str().c_str(), + a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), + c4in.str().c_str(), c4op.str().c_str(), + fopacity.str().c_str(), sopacity.str().c_str() ); return _filter; }; /* Outline filter */ diff --git a/src/filter-chemistry.cpp b/src/filter-chemistry.cpp index e98905439..9ea9407b1 100644 --- a/src/filter-chemistry.cpp +++ b/src/filter-chemistry.cpp @@ -123,7 +123,7 @@ filter_add_primitive(SPFilter *filter, const Inkscape::Filters::FilterPrimitiveT // set default values switch(type) { case Inkscape::Filters::NR_FILTER_BLEND: - repr->setAttribute("blend", "normal"); + repr->setAttribute("mode", "normal"); break; case Inkscape::Filters::NR_FILTER_COLORMATRIX: break; |
