From: JazzyNico Date: Sun, 12 Sep 2010 12:17:52 +0000 (+0200) Subject: Filters. New customizable Bicolorizer filter (experimental). X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=fe0a749f3f5f5db0795efe3e43a8c390bec44cc3;p=inkscape.git Filters. New customizable Bicolorizer filter (experimental). --- diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h new file mode 100644 index 000000000..4fd60aab8 --- /dev/null +++ b/src/extension/internal/filter/color.h @@ -0,0 +1,115 @@ +#ifndef __INKSCAPE_EXTENSION_INTERNAL_FILTER_COLOR_H__ +#define __INKSCAPE_EXTENSION_INTERNAL_FILTER_COLOR_H__ +/* Change the 'COLOR' above to be your file name */ + +/* + * Copyright (C) 2010 Authors: + * Ivan Louette (filters) + * Nicolas Dufour (UI) + * + * 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 { + +class Bicolorizer : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + Bicolorizer ( ) : Filter() { }; + virtual ~Bicolorizer ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "\n" + "" N_("Bicolorizer -EXP-") "\n" + "org.inkscape.effect.filter.bicolorizer\n" +// Using color widgets in tabs makes Inkscape crash... +// "\n" +// "\n" + "<_param name=\"header1\" type=\"groupheader\">Color 1\n" + "1946122495\n" +// "\n" +// "\n" + "<_param name=\"header2\" type=\"groupheader\">Color 2\n" + "367387135\n" +// "\n" +// "\n" + "\n" + "all\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "" N_("Change colors to a two colors palette") "\n" + "\n" + "\n", new Bicolorizer()); + }; + +}; + +gchar const * +Bicolorizer::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream a1; + std::ostringstream r1; + std::ostringstream g1; + std::ostringstream b1; + std::ostringstream a2; + std::ostringstream r2; + std::ostringstream g2; + std::ostringstream b2; + + guint32 color1 = ext->get_param_color("color1"); + guint32 color2 = ext->get_param_color("color2"); + a1 << (color1 & 0xff) / 255.0F; + r1 << ((color1 >> 24) & 0xff); + g1 << ((color1 >> 16) & 0xff); + b1 << ((color1 >> 8) & 0xff); + a2 << (color2 & 0xff) / 255.0F; + r2 << ((color2 >> 24) & 0xff); + g2 << ((color2 >> 16) & 0xff); + b2 << ((color2 >> 8) & 0xff); + + _filter = g_strdup_printf( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", a1.str().c_str(), r1.str().c_str(), g1.str().c_str(), b1.str().c_str(), a2.str().c_str(), r2.str().c_str(), g2.str().c_str(), b2.str().c_str()); + + return _filter; +}; +}; /* namespace Filter */ +}; /* namespace Internal */ +}; /* namespace Extension */ +}; /* namespace Inkscape */ + +/* Change the 'COLOR' below to be your file name */ +#endif /* __INKSCAPE_EXTENSION_INTERNAL_FILTER_COLOR_H__ */ diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp index 6d61501fb..de683ba83 100644 --- a/src/extension/internal/filter/filter-all.cpp +++ b/src/extension/internal/filter/filter-all.cpp @@ -8,6 +8,7 @@ #include "filter.h" /* Put your filter here */ +#include "color.h" #include "drop-shadow.h" #include "snow.h" @@ -21,6 +22,7 @@ void Filter::filters_all (void ) { // Here come the filters which are coded in C++ in order to present a parameters dialog + Bicolorizer::init(); DropShadow::init(); DropGlow::init(); ColorizableDropShadow::init();