summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/extension/internal/filter/bumps.h4
-rw-r--r--src/extension/internal/filter/color.h4
-rwxr-xr-xsrc/extension/internal/filter/filter-all.cpp1
-rw-r--r--src/extension/internal/filter/paint.h32
-rw-r--r--src/extension/internal/filter/transparency.h77
5 files changed, 97 insertions, 21 deletions
diff --git a/src/extension/internal/filter/bumps.h b/src/extension/internal/filter/bumps.h
index c80ca004a..e9860f4a7 100644
--- a/src/extension/internal/filter/bumps.h
+++ b/src/extension/internal/filter/bumps.h
@@ -698,11 +698,11 @@ 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(255,255,255)\" result=\"flood1\" />\n"
+ "<feFlood 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 flood-color=\"rgb(%s,%s,%s)\" flood-opacity=\"%s\" result=\"flood2\" />\n"
- "<feComposite in=\"flood2\" in2=\"colormatrix2\" stdDeviation=\"1\" operator=\"%s\" result=\"composite1\" />\n"
+ "<feComposite in=\"flood2\" in2=\"colormatrix2\" 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"
diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h
index 7a055b240..343a5eb84 100644
--- a/src/extension/internal/filter/color.h
+++ b/src/extension/internal/filter/color.h
@@ -590,7 +590,7 @@ Duochrome::get_filter_text (Inkscape::Extension::Extension * ext)
"<feColorMatrix type=\"luminanceToAlpha\" result=\"colormatrix1\" />\n"
"<feFlood flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood1\" />\n"
"<feComposite in2=\"colormatrix1\" operator=\"%s\" result=\"composite1\" />\n"
- "<feFlood in=\"colormatrix1\" flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood2\" />\n"
+ "<feFlood flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood2\" />\n"
"<feComposite in2=\"colormatrix1\" result=\"composite2\" operator=\"%s\" />\n"
"<feComposite in=\"composite2\" in2=\"composite1\" k2=\"1\" k3=\"1\" operator=\"arithmetic\" result=\"composite3\" />\n"
"<feColorMatrix in=\"composite3\" type=\"matrix\" values=\"2 -1 0 0 0 0 2 -1 0 0 -1 0 2 0 0 0 0 0 1 0 \" result=\"colormatrix2\" />\n"
@@ -988,7 +988,7 @@ Lightness::get_filter_text (Inkscape::Extension::Extension * ext)
_filter = g_strdup_printf(
"<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Lightness\">\n"
- "<feComponentTransfer in=\"blur\" stdDeviation=\"2\" result=\"component\" >\n"
+ "<feComponentTransfer in=\"blur\" result=\"component\" >\n"
"<feFuncR type=\"gamma\" amplitude=\"%s\" exponent=\"%s\" offset=\"%s\" />\n"
"<feFuncG type=\"gamma\" amplitude=\"%s\" exponent=\"%s\" offset=\"%s\" />\n"
"<feFuncB type=\"gamma\" amplitude=\"%s\" exponent=\"%s\" offset=\"%s\" />\n"
diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp
index 251402762..092edff18 100755
--- a/src/extension/internal/filter/filter-all.cpp
+++ b/src/extension/internal/filter/filter-all.cpp
@@ -100,6 +100,7 @@ Filter::filters_all (void )
// Fill and transparency
Blend::init();
ChannelTransparency::init();
+ LightEraser::init();
Silhouette::init();
// Here come the rest of the filters that are read from SVG files in share/filters and
diff --git a/src/extension/internal/filter/paint.h b/src/extension/internal/filter/paint.h
index 5d79b6c3b..0546b672f 100644
--- a/src/extension/internal/filter/paint.h
+++ b/src/extension/internal/filter/paint.h
@@ -184,16 +184,16 @@ Chromolitho::get_filter_text (Inkscape::Extension::Extension * ext)
_filter = g_strdup_printf(
"<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"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"
+ "<feComposite 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\" result=\"convolve1\" />\n"
+ "<feBlend in=\"%s\" in2=\"composite1\" mode=\"%s\" blend=\"normal\" result=\"blend1\" />\n"
"<feGaussianBlur in=\"blend1\" stdDeviation=\"%s\" result=\"blur1\" />\n"
"<feTurbulence baseFrequency=\"%s %s\" numOctaves=\"%s\" seed=\"%s\" type=\"fractalNoise\" result=\"turbulence1\" />\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"
- "<feColorMatrix type=\"saturate\" stdDeviation=\"3\" values=\"%s\" result=\"colormatrix2\" />\n"
- "<feBlend in=\"%s\" in2=\"blur1\" stdDeviation=\"1\" blend=\"normal\" mode=\"%s\" result=\"blend2\" />\n"
+ "<feColorMatrix type=\"saturate\" values=\"%s\" result=\"colormatrix2\" />\n"
+ "<feBlend in=\"%s\" in2=\"blur1\" blend=\"normal\" mode=\"%s\" result=\"blend2\" />\n"
"<feColorMatrix in=\"blend2\" type=\"saturate\" values=\"%s\" result=\"colormatrix3\" />\n"
- "<feComponentTransfer in=\"colormatrix3\" stdDeviation=\"2\" result=\"component1\">\n"
+ "<feComponentTransfer in=\"colormatrix3\" result=\"component1\">\n"
"<feFuncR type=\"discrete\" tableValues=\"%s\" />\n"
"<feFuncG type=\"discrete\" tableValues=\"%s\" />\n"
"<feFuncB type=\"discrete\" tableValues=\"%s\" />\n"
@@ -437,19 +437,19 @@ Drawing::get_filter_text (Inkscape::Extension::Extension * ext)
"<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"
+ "<feComposite in=\"convolve1\" in2=\"convolve1\" k1=\"1\" k2=\"1\" k4=\"%s\" 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"
"<feGaussianBlur stdDeviation=\"%s\" result=\"blur2\" />\n"
"<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 %s %s \" result=\"color2\" />\n"
"<feFlood flood-color=\"rgb(255,255,255)\" result=\"flood1\" />\n"
"<feBlend in2=\"color2\" mode=\"multiply\" blend=\"normal\" result=\"blend1\" />\n"
- "<feComponentTransfer in=\"blend1\" stdDeviation=\"2\" result=\"component1\">\n"
+ "<feComponentTransfer in=\"blend1\" result=\"component1\">\n"
"<feFuncR type=\"discrete\" tableValues=\"0 1 1 1\" />\n"
"<feFuncG type=\"discrete\" tableValues=\"0 1 1 1\" />\n"
"<feFuncB type=\"discrete\" tableValues=\"0 1 1 1\" />\n"
"</feComponentTransfer>\n"
"<feGaussianBlur stdDeviation=\"%s\" result=\"blur3\" />\n"
- "<feColorMatrix in=\"blur3\" values=\"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.2125 -0.7154 -0.0721 1 0 \" stdDeviation=\"1\" result=\"color3\" />\n"
+ "<feColorMatrix in=\"blur3\" values=\"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.2125 -0.7154 -0.0721 1 0 \" result=\"color3\" />\n"
"<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 %s %s \" result=\"color4\" />\n"
"<feFlood flood-color=\"rgb(%s,%s,%s)\" result=\"flood2\" />\n"
"<feComposite in=\"%s\" in2=\"color4\" operator=\"in\" result=\"composite2\" />\n"
@@ -546,7 +546,7 @@ Electrize::get_filter_text (Inkscape::Extension::Extension * ext)
_filter = g_strdup_printf(
"<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Electrize\">\n"
"<feGaussianBlur stdDeviation=\"%s\" result=\"blur\" />\n"
- "<feComponentTransfer in=\"blur\" stdDeviation=\"2\" result=\"component\" >\n"
+ "<feComponentTransfer in=\"blur\" result=\"component\" >\n"
"<feFuncR type=\"%s\" tableValues=\"%s\" />\n"
"<feFuncG type=\"%s\" tableValues=\"%s\" />\n"
"<feFuncB type=\"%s\" tableValues=\"%s\" />\n"
@@ -796,12 +796,12 @@ PointEngraving::get_filter_text (Inkscape::Extension::Extension * ext)
if (ext->get_param_bool("iof"))
iof << "SourceGraphic";
else
- iof << "flood1";
+ iof << "flood2";
if (ext->get_param_bool("iop"))
iop << "SourceGraphic";
else
- iop << "flood2";
+ iop << "flood1";
_filter = g_strdup_printf(
"<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" inkscape:label=\"Point Engraving\" x=\"0\" y=\"0\" width=\"1\" height=\"1\" color-interpolation-filters=\"sRGB\">\n"
@@ -814,16 +814,16 @@ PointEngraving::get_filter_text (Inkscape::Extension::Extension * ext)
"<feGaussianBlur stdDeviation=\"%s\" result=\"blur\" />\n"
"<feFlood flood-color=\"rgb(%s,%s,%s)\" flood-opacity=\"%s\" result=\"flood1\" />\n"
"<feComposite in=\"%s\" in2=\"blur\" operator=\"out\" result=\"composite2\" />\n"
- "<feFlood in=\"blur\" flood-color=\"rgb(%s,%s,%s)\" flood-opacity=\"%s\" result=\"flood2\" />\n"
+ "<feFlood flood-color=\"rgb(%s,%s,%s)\" flood-opacity=\"%s\" result=\"flood2\" />\n"
"<feComposite in=\"%s\" in2=\"blur\" operator=\"in\" result=\"composite3\" />\n"
"<feComposite in=\"composite3\" in2=\"composite2\" k2=\"%s\" k3=\"%s\" operator=\"arithmetic\" result=\"composite4\" />\n"
"<feComposite in2=\"SourceGraphic\" operator=\"in\" result=\"composite5\" />\n"
"</filter>\n", reduction.str().c_str(), blend.str().c_str(),
type.str().c_str(), hfreq.str().c_str(), vfreq.str().c_str(), complexity.str().c_str(), variation.str().c_str(),
lightness.str().c_str(), grain.str().c_str(), erase.str().c_str(), blur.str().c_str(),
- r.str().c_str(), g.str().c_str(), b.str().c_str(), a.str().c_str(), iof.str().c_str(),
br.str().c_str(), bg.str().c_str(), bb.str().c_str(), ba.str().c_str(), iop.str().c_str(),
- ba.str().c_str(), a.str().c_str() );
+ r.str().c_str(), g.str().c_str(), b.str().c_str(), a.str().c_str(), iof.str().c_str(),
+ a.str().c_str(), ba.str().c_str() );
return _filter;
}; /* Point engraving filter */
@@ -1020,7 +1020,7 @@ PosterizeBasic::get_filter_text (Inkscape::Extension::Extension * ext)
_filter = g_strdup_printf(
"<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Posterize Basic\">\n"
"<feGaussianBlur stdDeviation=\"%s\" result=\"blur1\" />\n"
- "<feComponentTransfer stdDeviation=\"2\" in=\"blur1\" result=\"component1\">\n"
+ "<feComponentTransfer in=\"blur1\" result=\"component1\">\n"
"<feFuncR type=\"discrete\" tableValues=\"%s\" />\n"
"<feFuncG type=\"discrete\" tableValues=\"%s\" />\n"
"<feFuncB type=\"discrete\" tableValues=\"%s\" />\n"
diff --git a/src/extension/internal/filter/transparency.h b/src/extension/internal/filter/transparency.h
index a73191bcc..48322ae43 100644
--- a/src/extension/internal/filter/transparency.h
+++ b/src/extension/internal/filter/transparency.h
@@ -10,6 +10,7 @@
* Fill and transparency filters
* Blend
* Channel transparency
+ * Light eraser
* Silhouette
*
* Released under GNU GPL, read the file 'COPYING' for more information
@@ -168,7 +169,7 @@ ChannelTransparency::get_filter_text (Inkscape::Extension::Extension * ext)
}
_filter = g_strdup_printf(
- "<filter inkscape:label=\"Channel Transparency\" color-interpolation-filters=\"sRGB\" x=\"0\" y=\"0\" width=\"1\" height=\"1\">\n"
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" 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(),
@@ -178,6 +179,80 @@ ChannelTransparency::get_filter_text (Inkscape::Extension::Extension * ext)
}; /* Channel transparency filter */
/**
+ \brief Custom predefined LightEraser filter.
+
+ Make the lightest parts of the object progressively transparent.
+
+ Filter's parameters:
+ * Expand (1->1000, default 250) -> colormatrix (first 3 values, multiplicator)
+ * Erode (0->1000, default 75) -> colormatrix (4th value, multiplicator)
+ * Global opacity (0.->1., default 1.) -> composite (k2)
+ * Inverted (boolean, default false) -> colormatrix (values, true: first 3 values positive, 4th negative)
+
+*/
+class LightEraser : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ LightEraser ( ) : Filter() { };
+ virtual ~LightEraser ( ) { 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_("Light Eraser") "</name>\n"
+ "<id>org.inkscape.effect.filter.LightEraser</id>\n"
+ "<param name=\"expand\" gui-text=\"" N_("Expansion:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"1000\">100</param>\n"
+ "<param name=\"erode\" gui-text=\"" N_("Erosion:") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"1000\">50</param>\n"
+ "<param name=\"opacity\" gui-text=\"" N_("Global opacity:") "\" 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_("Make the lightest parts of the object progressively transparent") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new LightEraser());
+ };
+};
+
+gchar const *
+LightEraser::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream expand;
+ std::ostringstream erode;
+ std::ostringstream opacity;
+
+ opacity << ext->get_param_float("opacity");
+
+ if (ext->get_param_bool("invert")) {
+ expand << (ext->get_param_int("expand") * 0.2125) << " "
+ << (ext->get_param_int("expand") * 0.7154) << " "
+ << (ext->get_param_int("expand") * 0.0721);
+ erode << (-ext->get_param_int("erode") * 720 / 1000);
+ } else {
+ expand << (-ext->get_param_int("expand") * 0.2125) << " "
+ << (-ext->get_param_int("expand") * 0.7154) << " "
+ << (-ext->get_param_int("expand") * 0.0721);
+ erode << (ext->get_param_int("erode") * 720 / 1000);
+ }
+
+ _filter = g_strdup_printf(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" inkscape:label=\"Light Eraser\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" color-interpolation-filters=\"sRGB\" >\n"
+ "<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 %s %s 0 \" result=\"colormatrix\" />\n"
+ "<feComposite in2=\"colormatrix\" operator=\"arithmetic\" k2=\"%s\" result=\"composite\" />\n"
+ "</filter>\n", expand.str().c_str(), erode.str().c_str(), opacity.str().c_str());
+
+ return _filter;
+}; /* Light Eraser filter */
+
+/**
\brief Custom predefined Silhouette filter.
Repaint anything visible monochrome