From: JazzyNico Date: Fri, 10 Sep 2010 20:18:10 +0000 (+0200) Subject: Filters. New Customizable Colored Drop Shadow filter (experimental). X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=173bd419c7e2a1eb1f13bf9fca89ac79aa37096e;p=inkscape.git Filters. New Customizable Colored Drop Shadow filter (experimental). --- diff --git a/src/extension/internal/filter/drop-shadow.h b/src/extension/internal/filter/drop-shadow.h index 12f0c6055..914d9cf9d 100644 --- a/src/extension/internal/filter/drop-shadow.h +++ b/src/extension/internal/filter/drop-shadow.h @@ -141,6 +141,71 @@ DropGlow::get_filter_text (Inkscape::Extension::Extension * ext) return _filter; }; +class ColorizableDropShadow : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + ColorizableDropShadow ( ) : Filter() { }; + virtual ~ColorizableDropShadow ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Drop shadow, color -EXP-") "\n" + "org.inkscape.effect.filter.colorizable-drop-shadow\n" + "3.0\n" + "6.0\n" + "6.0\n" + "0\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Colorizable Drop shadow") "\n" + "\n" + "\n", new ColorizableDropShadow()); + }; + +}; + +gchar const * +ColorizableDropShadow::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream blur; + std::ostringstream a; + std::ostringstream r; + std::ostringstream g; + std::ostringstream b; + std::ostringstream x; + std::ostringstream y; + + guint32 color = ext->get_param_color("color"); + + blur << ext->get_param_float("blur"); + x << ext->get_param_float("xoffset"); + y << ext->get_param_float("yoffset"); + a << (color & 0xff) / 255.0F; + r << ((color >> 24) & 0xff); + g << ((color >> 16) & 0xff); + b << ((color >> 8) & 0xff); + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), blur.str().c_str(), x.str().c_str(), y.str().c_str()); + + return _filter; +}; }; /* namespace Filter */ }; /* namespace Internal */ }; /* namespace Extension */ diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp index b4b8caf81..6d61501fb 100644 --- a/src/extension/internal/filter/filter-all.cpp +++ b/src/extension/internal/filter/filter-all.cpp @@ -23,6 +23,7 @@ Filter::filters_all (void ) // Here come the filters which are coded in C++ in order to present a parameters dialog DropShadow::init(); DropGlow::init(); + ColorizableDropShadow::init(); Snow::init(); // Here come the rest of the filters that are read from SVG files in share/filters and