summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNicolas Dufour <nicoduf@yahoo.fr>2011-08-10 19:39:47 +0000
committerJazzyNico <nicoduf@yahoo.fr>2011-08-10 19:39:47 +0000
commitc1e8d3c29bde66b87e8f19bb859d074e77a9e982 (patch)
treed4c04e5ecf65aa10a2a9bcbe4b10b962417b35df /src
parentFilters. New Invert, Wax bump and Felt feather custom predefined filters. (diff)
downloadinkscape-c1e8d3c29bde66b87e8f19bb859d074e77a9e982.tar.gz
inkscape-c1e8d3c29bde66b87e8f19bb859d074e77a9e982.zip
Filters. New Blend, Extract Channel and Ink Blot custom predefined filters.
(bzr r10534)
Diffstat (limited to 'src')
-rw-r--r--src/extension/internal/filter/bumps.h3
-rw-r--r--src/extension/internal/filter/color.h103
-rwxr-xr-xsrc/extension/internal/filter/filter-all.cpp5
-rw-r--r--src/extension/internal/filter/transparency.h68
4 files changed, 176 insertions, 3 deletions
diff --git a/src/extension/internal/filter/bumps.h b/src/extension/internal/filter/bumps.h
index 9d46a25b2..b8617eafc 100644
--- a/src/extension/internal/filter/bumps.h
+++ b/src/extension/internal/filter/bumps.h
@@ -698,13 +698,12 @@ WaxBump::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=\"Wax Bump\">\n"
"<feGaussianBlur in=\"SourceGraphic\" stdDeviation=\"%s\" result=\"blur1\" />\n"
- "<feFlood in=\"SourceGraphic\" flood-opacity=\"1\" flood-color=\"rgb(0,255,255)\" result=\"flood1\" />\n"
+ "<feFlood in=\"SourceGraphic\" flood-opacity=\"1\" flood-color=\"rgb(255,255,255)\" result=\"flood1\" />\n"
"<feColorMatrix in=\"%s\" values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 %s \" result=\"colormatrix1\" />\n"
"<feColorMatrix in=\"blur1\" values=\"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 %s %s %s %s 0 \" result=\"colormatrix2\" />\n"
"<feFlood stdDeviation=\"1\" flood-color=\"rgb(%s,%s,%s)\" flood-opacity=\"%s\" result=\"flood2\" />\n"
"<feComposite in=\"flood2\" in2=\"colormatrix2\" stdDeviation=\"1\" operator=\"%s\" result=\"composite1\" />\n"
"<feGaussianBlur in=\"composite1\" stdDeviation=\"%s\" result=\"blur2\" />\n"
-
"<feSpecularLighting in=\"blur2\" lighting-color=\"rgb(%s,%s,%s)\" specularConstant=\"%s\" surfaceScale=\"%s\" specularExponent=\"%s\" result=\"specular\">\n"
"<feDistantLight elevation=\"%s\" azimuth=\"%s\" />\n"
"</feSpecularLighting>\n"
diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h
index b34c2c61f..fb6ea0ab9 100644
--- a/src/extension/internal/filter/color.h
+++ b/src/extension/internal/filter/color.h
@@ -13,6 +13,7 @@
* Color shift
* Colorize
* Duochrome
+ * Extract channel
* Greyscale
* Invert
* Lightness
@@ -518,6 +519,108 @@ Duochrome::get_filter_text (Inkscape::Extension::Extension * ext)
}; /* Duochrome filter */
/**
+ \brief Custom predefined Extract Channel filter.
+
+ Extract color channel as a transparent image.
+
+ Filter's parameters:
+ * Channel (enum, all colors, default Red) -> colormatrix (values)
+ * Background blend (enum, all blend modes, default Multiply) -> blend (mode)
+ * Channel to alpha (boolean, default false) -> colormatrix (values)
+ * Invert (boolean, default false) -> colormatrix (values)
+
+*/
+class ExtractChannel : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ ExtractChannel ( ) : Filter() { };
+ virtual ~ExtractChannel ( ) { 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_("Extract Channel") "</name>\n"
+ "<id>org.inkscape.effect.filter.ExtractChannel</id>\n"
+ "<param name=\"source\" gui-text=\"" N_("Channel:") "\" type=\"enum\">\n"
+ "<_item value=\"r\">" N_("Red") "</_item>\n"
+ "<_item value=\"g\">" N_("Green") "</_item>\n"
+ "<_item value=\"b\">" N_("Blue") "</_item>\n"
+ "</param>\n"
+ "<param name=\"blend\" gui-text=\"" N_("Background blend mode:") "\" type=\"enum\">\n"
+ "<_item value=\"multiply\">" N_("Multiply") "</_item>\n"
+ "<_item value=\"normal\">" N_("Normal") "</_item>\n"
+ "<_item value=\"screen\">" N_("Screen") "</_item>\n"
+ "<_item value=\"darken\">" N_("Darken") "</_item>\n"
+ "<_item value=\"lighten\">" N_("Lighten") "</_item>\n"
+ "</param>\n"
+ "<param name=\"alpha\" gui-text=\"" N_("Channel to alpha") "\" type=\"boolean\">false</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_("Color") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Extract color channel as a transparent image") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new ExtractChannel());
+ };
+};
+
+gchar const *
+ExtractChannel::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream blend;
+ std::ostringstream colors;
+ std::ostringstream alpha;
+ std::ostringstream invert;
+
+ blend << ext->get_param_enum("blend");
+
+ const gchar *channel = ext->get_param_enum("source");
+ if (ext->get_param_bool("alpha")) {
+ colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0";
+ } else if ((g_ascii_strcasecmp("r", channel) == 0)) {
+ colors << "0 0 0 0 1 0 0 0 0 0 0 0 0 0 0";
+ } else if ((g_ascii_strcasecmp("g", channel) == 0)) {
+ colors << "0 0 0 0 0 0 0 0 0 1 0 0 0 0 0";
+ } else {
+ colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 1";
+ }
+
+ if (ext->get_param_bool("invert")) {
+ if ((g_ascii_strcasecmp("r", channel) == 0)) {
+ alpha << "-1 0 0 1";
+ } else if ((g_ascii_strcasecmp("g", channel) == 0)) {
+ alpha << "0 -1 0 1";
+ } else {
+ alpha << "0 0 -1 1";
+ }
+ } else {
+ if ((g_ascii_strcasecmp("r", channel) == 0)) {
+ alpha << "1 0 0 0";
+ } else if ((g_ascii_strcasecmp("g", channel) == 0)) {
+ alpha << "0 1 0 0";
+ } else {
+ alpha << "0 0 1 0";
+ }
+ }
+
+ _filter = g_strdup_printf(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Extract Channel\">\n"
+ "<feColorMatrix in=\"SourceGraphic\" values=\"%s %s %s 0 \" result=\"colormatrix\" />\n"
+ "<feBlend in2=\"BackgroundImage\" blend=\"normal\" mode=\"%s\" result=\"blend\" />\n"
+ "</filter>\n", colors.str().c_str(), alpha.str().c_str(), invert.str().c_str(), blend.str().c_str() );
+
+ return _filter;
+}; /* ExtractChannel filter */
+
+/**
\brief Custom predefined Greyscale filter.
Customize greyscale components.
diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp
index dcd68b75a..30376d231 100755
--- a/src/extension/internal/filter/filter-all.cpp
+++ b/src/extension/internal/filter/filter-all.cpp
@@ -18,6 +18,7 @@
#include "paint.h"
#include "protrusions.h"
#include "shadows.h"
+#include "textures.h"
#include "transparency.h"
namespace Inkscape {
@@ -53,6 +54,7 @@ Filter::filters_all (void )
ColorShift::init();
Colorize::init();
Duochrome::init();
+ ExtractChannel::init();
Greyscale::init();
Invert::init();
Lightness::init();
@@ -91,9 +93,10 @@ Filter::filters_all (void )
ColorizableDropShadow::init();
// Textures
- // InkBlot::init();
+ InkBlot::init();
// Fill and transparency
+ Blend::init();
ChannelTransparency::init();
Silhouette::init();
diff --git a/src/extension/internal/filter/transparency.h b/src/extension/internal/filter/transparency.h
index f8f02575b..9fd6cac22 100644
--- a/src/extension/internal/filter/transparency.h
+++ b/src/extension/internal/filter/transparency.h
@@ -8,6 +8,7 @@
* Nicolas Dufour (UI) <nicoduf@yahoo.fr>
*
* Fill and transparency filters
+ * Blend
* Channel transparency
* Silhouette
*
@@ -27,6 +28,73 @@ namespace Internal {
namespace Filter {
/**
+ \brief Custom predefined Blend filter.
+
+ Blend objecs with background images or with themselves
+
+ Filter's parameters:
+ * Source (enum [SourceGraphic,BackgroundImage], default BackgroundImage) -> blend (in2)
+ * Mode (enum, all blend modes, default Multiply) -> blend (mode)
+*/
+
+class Blend : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ Blend ( ) : Filter() { };
+ virtual ~Blend ( ) { 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_("Blend") "</name>\n"
+ "<id>org.inkscape.effect.filter.Blend</id>\n"
+ "<param name=\"source\" gui-text=\"" N_("Source:") "\" type=\"enum\">\n"
+ "<_item value=\"BackgroundImage\">" N_("Background") "</_item>\n"
+ "<_item value=\"SourceGraphic\">" N_("Image") "</_item>\n"
+ "</param>\n"
+ "<param name=\"mode\" gui-text=\"" N_("Mode:") "\" type=\"enum\">\n"
+ "<_item value=\"multiply\">" N_("Multiply") "</_item>\n"
+ "<_item value=\"normal\">" N_("Normal") "</_item>\n"
+ "<_item value=\"screen\">" N_("Screen") "</_item>\n"
+ "<_item value=\"darken\">" N_("Darken") "</_item>\n"
+ "<_item value=\"lighten\">" N_("Lighten") "</_item>\n"
+ "</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_("Blend objecs with background images or with themselves") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new Blend());
+ };
+
+};
+
+gchar const *
+Blend::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream source;
+ std::ostringstream mode;
+
+ source << ext->get_param_enum("source");
+ mode << ext->get_param_enum("mode");
+
+ _filter = g_strdup_printf(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Blend\">\n"
+ "<feBlend blend=\"normal\" in2=\"%s\" mode=\"%s\" result=\"blend\" />\n"
+ "</filter>\n", source.str().c_str(), mode.str().c_str() );
+
+ return _filter;
+}; /* Blend filter */
+
+/**
\brief Custom predefined Channel transparency filter.
Channel transparency filter.