From 29ea1bcd2b784536d5eb24f71d09e08720155397 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Tue, 16 Aug 2011 22:10:08 +0200 Subject: Filters. Fixes for SVG validation (now 100% pass). Filters. New Light Eraser CPF. Translations. inkscape.pot and French translation update. (bzr r10547) --- src/extension/internal/filter/bumps.h | 4 +- src/extension/internal/filter/color.h | 4 +- src/extension/internal/filter/filter-all.cpp | 1 + src/extension/internal/filter/paint.h | 32 ++++++------ src/extension/internal/filter/transparency.h | 77 +++++++++++++++++++++++++++- 5 files changed, 97 insertions(+), 21 deletions(-) (limited to 'src') 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( "\n" "\n" - "\n" + "\n" "\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "\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) "\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "\n" @@ -988,7 +988,7 @@ Lightness::get_filter_text (Inkscape::Extension::Extension * ext) _filter = g_strdup_printf( "\n" - "\n" + "\n" "\n" "\n" "\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( "\n" - "\n" - "\n" - "\n" + "\n" + "\n" + "\n" "\n" "\n" "\n" - "\n" - "\n" + "\n" + "\n" "\n" - "\n" + "\n" "\n" "\n" "\n" @@ -437,19 +437,19 @@ Drawing::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "\n" @@ -546,7 +546,7 @@ Electrize::get_filter_text (Inkscape::Extension::Extension * ext) _filter = g_strdup_printf( "\n" "\n" - "\n" + "\n" "\n" "\n" "\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( "\n" @@ -814,16 +814,16 @@ PointEngraving::get_filter_text (Inkscape::Extension::Extension * ext) "\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "\n" "\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( "\n" "\n" - "\n" + "\n" "\n" "\n" "\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( - "\n" + "\n" "\n" "\n" "\n", red.str().c_str(), green.str().c_str(), blue.str().c_str(), alpha.str().c_str(), @@ -177,6 +178,80 @@ ChannelTransparency::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* 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( + "\n" + "" N_("Light Eraser") "\n" + "org.inkscape.effect.filter.LightEraser\n" + "100\n" + "50\n" + "1\n" + "false\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Make the lightest parts of the object progressively transparent") "\n" + "\n" + "\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( + "\n" + "\n" + "\n" + "\n", expand.str().c_str(), erode.str().c_str(), opacity.str().c_str()); + + return _filter; +}; /* Light Eraser filter */ + /** \brief Custom predefined Silhouette filter. -- cgit v1.2.3