From 3d4c30d84221a63cde583267004f79ff74430f4c Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 27 Jul 2011 20:52:17 +0200 Subject: Filters. New Channel transparency and Cross blur custom predefined filters. Extensions. Barcode extensions reorganization. Translations. inkscape.pot and French translation update. (bzr r10509) --- src/extension/internal/filter/blurs.h | 114 +++++++++++++++++++++++++++ src/extension/internal/filter/color.h | 85 ++++++++++++++++++++ src/extension/internal/filter/filter-all.cpp | 9 +++ 3 files changed, 208 insertions(+) create mode 100644 src/extension/internal/filter/blurs.h (limited to 'src') diff --git a/src/extension/internal/filter/blurs.h b/src/extension/internal/filter/blurs.h new file mode 100644 index 000000000..957484cbb --- /dev/null +++ b/src/extension/internal/filter/blurs.h @@ -0,0 +1,114 @@ +#ifndef __INKSCAPE_EXTENSION_INTERNAL_FILTER_BLURS_H__ +#define __INKSCAPE_EXTENSION_INTERNAL_FILTER_BLURS_H__ +/* Change the 'BLURS' above to be your file name */ + +/* + * Copyright (C) 2011 Authors: + * Ivan Louette (filters) + * Nicolas Dufour (UI) + * + * Blur filters + * Cross blur + * + * 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 Cross blur filter. + + Combine vertical and horizontal blur + + Filter's parameters: + * Brighness (0.->10., default 0) -> composite (k3) + * Fading (0.->1., default 0) -> composite (k4) + * Horizontal blur (0.01->20., default 5) -> blur (stdDeviation) + * Vertical blur (0.01->20., default 5) -> blur (stdDeviation) + * Blend mode (enum, default Darken) -> blend (mode) +*/ + +class CrossBlur : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + CrossBlur ( ) : Filter() { }; + virtual ~CrossBlur ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Cross blur, custom (Blurs)") "\n" + "org.inkscape.effect.filter.CrossBlur\n" + "0\n" + "0\n" + "5\n" + "5\n" + "\n" + "<_item value=\"darken\">" N_("Darken") "\n" + "<_item value=\"screen\">" N_("Screen") "\n" + "<_item value=\"multiply\">" N_("Multiply") "\n" + "<_item value=\"lighten\">" N_("Lighten") "\n" + "\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Combine vertical and horizontal blur") "\n" + "\n" + "\n", new CrossBlur()); + }; + +}; + +gchar const * +CrossBlur::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream bright; + std::ostringstream fade; + std::ostringstream hblur; + std::ostringstream vblur; + std::ostringstream blend; + + bright << ext->get_param_float("bright"); + fade << ext->get_param_float("fade"); + hblur << ext->get_param_float("hblur"); + vblur << ext->get_param_float("vblur"); + blend << ext->get_param_enum("blend"); + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", bright.str().c_str(), fade.str().c_str(), hblur.str().c_str(), vblur.str().c_str(), blend.str().c_str()); + + return _filter; +}; /* Cross blur filter */ + + +}; /* namespace Filter */ +}; /* namespace Internal */ +}; /* namespace Extension */ +}; /* namespace Inkscape */ + +/* Change the 'BLURS' below to be your file name */ +#endif /* __INKSCAPE_EXTENSION_INTERNAL_FILTER_BLURS_H__ */ diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index 4f9954b2c..2df92df29 100755 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -10,6 +10,7 @@ * Color filters * Brightness * Channel painting + * Channel transparency * Colorize * Duochrome * Electrize @@ -225,6 +226,90 @@ ChannelPaint::get_filter_text (Inkscape::Extension::Extension * ext) }; /* Channel Painting filter */ +/** + \brief Custom predefined Channel transparency filter. + + Channel transparency filter. + + Filter's parameters: + * Saturation (0.->1., default 1.) -> colormatrix1 (values) + * Red (-10.->10., default -1.) -> colormatrix2 (values) + * Green (-10.->10., default 0.5) -> colormatrix2 (values) + * Blue (-10.->10., default 0.5) -> colormatrix2 (values) + * Alpha (-10.->10., default 1.) -> colormatrix2 (values) + * Flood colors (guint, default 16777215) -> flood (flood-opacity, flood-color) + * Inverted (boolean, default false) -> composite1 (operator, true='in', false='out') + + Matrix: + 1 0 0 0 0 + 0 1 0 0 0 + 0 0 1 0 0 + R G B A 0 +*/ +class ChannelTransparency : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + ChannelTransparency ( ) : Filter() { }; + virtual ~ChannelTransparency ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Channel transparency, custom (Color)") "\n" + "org.inkscape.effect.filter.ChannelTransparency\n" + "-1\n" + "0.5\n" + "0.5\n" + "1\n" + "false\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Replace RGB by transparency") "\n" + "\n" + "\n", new ChannelTransparency()); + }; +}; + +gchar const * +ChannelTransparency::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream red; + std::ostringstream green; + std::ostringstream blue; + std::ostringstream alpha; + std::ostringstream invert; + + red << ext->get_param_float("red"); + green << ext->get_param_float("green"); + blue << ext->get_param_float("blue"); + alpha << ext->get_param_float("alpha"); + + if (!ext->get_param_bool("invert")) { + invert << "in"; + } else { + invert << "xor"; + } + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n", red.str().c_str(), green.str().c_str(), blue.str().c_str(), alpha.str().c_str(), + invert.str().c_str()); + + return _filter; +}; /* Channel Transparency filter */ + + /** \brief Custom predefined Colorize filter. diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp index 8a8dd57a6..ed8b4e180 100755 --- a/src/extension/internal/filter/filter-all.cpp +++ b/src/extension/internal/filter/filter-all.cpp @@ -9,6 +9,8 @@ /* Put your filter here */ #include "abc.h" +#include "blurs.h" +//#include "bumps.h" #include "color.h" #include "drop-shadow.h" #include "image.h" @@ -47,9 +49,16 @@ Filter::filters_all (void ) Silhouette::init(); SpecularLight::init(); + // Blurs + CrossBlur::init(); + + // Bumps +// SpecularBump::init(); + // Color Brightness::init(); ChannelPaint::init(); + ChannelTransparency::init(); Colorize::init(); Duochrome::init(); Electrize::init(); -- cgit v1.2.3