From 91537ab0f4c9166a95246e3e81e7d12e81b43bef Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Sun, 4 Feb 2018 08:30:27 +0000 Subject: New "Simple Blend" custom predefined filter effect (original idea by Ivan Louette). Patch 1/2 --- src/extension/internal/filter/color.h | 84 +++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index 6324dafa9..921ff3171 100644 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -24,6 +24,7 @@ * Nudge RGB * Nudge CMY * Quadritone + * Simple blend * Solarize * Tritone * @@ -1542,6 +1543,89 @@ Quadritone::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; /* Quadritone filter */ + +/** + \brief Custom predefined Simple blend filter. + + Simple blend filter. + + Filter's parameters: + * Color (guint, default 16777215) -> flood1 (flood-opacity, flood-color) + * Blend mode (enum, default Hue) -> blend1 (mode) +*/ +class SimpleBlend : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + SimpleBlend ( ) : Filter() { }; + virtual ~SimpleBlend ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Simple blend") "\n" + "org.inkscape.effect.filter.SimpleBlend\n" + "16777215\n" + "\n" + "<_item value=\"normal\">" N_("Normal") "\n" + "<_item value=\"multiply\">" N_("Multiply") "\n" + "<_item value=\"screen\">" N_("Screen") "\n" + "<_item value=\"saturation\">" N_("Saturation") "\n" + "<_item value=\"darken\">" N_("Darken") "\n" + "<_item value=\"difference\">" N_("Difference") "\n" + "<_item value=\"lighten\">" N_("Lighten") "\n" + "<_item value=\"luminosity\">" N_("Luminosity") "\n" + "<_item value=\"overlay\">" N_("Overlay") "\n" + "<_item value=\"color-dodge\">" N_("Color Dodge") "\n" + "<_item value=\"color-burn\">" N_("Color Burn") "\n" + "<_item value=\"color\">" N_("Color") "\n" + "<_item value=\"hard-light\">" N_("Hard Light") "\n" + "<_item value=\"hue\">" N_("Hue") "\n" + "<_item value=\"exclusion\">" N_("Exclusion") "\n" + "\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Simple blend filter") "\n" + "\n" + "\n", new SimpleBlend()); + }; +}; + +gchar const * +SimpleBlend::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 blend; + + guint32 color = ext->get_param_color("color"); + r << ((color >> 24) & 0xff); + g << ((color >> 16) & 0xff); + b << ((color >> 8) & 0xff); + a << (color & 0xff) / 255.0F; + blend << ext->get_param_enum("blendmode"); + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n", r.str().c_str(), g.str().c_str(), b.str().c_str(), + a.str().c_str(), blend.str().c_str()); + + return _filter; +}; /* SimpleBlend filter */ + /** \brief Custom predefined Solarize filter. -- cgit v1.2.3