summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNicolas Dufour <nicoduf@yahoo.fr>2010-09-10 20:18:10 +0000
committerJazzyNico <nicoduf@yahoo.fr>2010-09-10 20:18:10 +0000
commitd4baa2e2cc1453ef3b402ab55844b4b7bd7eaeab (patch)
treea492a1284f0b47963c4a0b90e1b16b9be093c081 /src
parentExtensions. Consistency fix and UI improvements (internal extensions and filt... (diff)
downloadinkscape-d4baa2e2cc1453ef3b402ab55844b4b7bd7eaeab.tar.gz
inkscape-d4baa2e2cc1453ef3b402ab55844b4b7bd7eaeab.zip
Filters. New Customizable Colored Drop Shadow filter (experimental).
(bzr r9755)
Diffstat (limited to 'src')
-rw-r--r--src/extension/internal/filter/drop-shadow.h65
-rw-r--r--src/extension/internal/filter/filter-all.cpp1
2 files changed, 66 insertions, 0 deletions
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(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Drop shadow, color -EXP-") "</name>\n"
+ "<id>org.inkscape.effect.filter.colorizable-drop-shadow</id>\n"
+ "<param name=\"blur\" gui-text=\"" N_("Blur radius (px):") "\" type=\"float\" min=\"0.0\" max=\"200.0\">3.0</param>\n"
+ "<param name=\"xoffset\" gui-text=\"" N_("Horizontal offset (px):") "\" type=\"float\" min=\"-50.0\" max=\"50.0\">6.0</param>\n"
+ "<param name=\"yoffset\" gui-text=\"" N_("Vertical offset (px):") "\" type=\"float\" min=\"-50.0\" max=\"50.0\">6.0</param>\n"
+ "<param name=\"color\" gui-text=\"" N_("Color") "\" type=\"color\">0</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"" N_("Shadows and Glows") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Colorizable Drop shadow") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\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(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1.2\" width=\"1.2\" y=\"-0.1\" x=\"-0.1\" inkscape:label=\"Drop shadow, color -EXP-\">\n"
+ "<feFlood flood-opacity=\"%s\" result=\"flood\" flood-color=\"rgb(%s,%s,%s)\" />\n"
+ "<feComposite in2=\"SourceGraphic\" in=\"flood\" result=\"composite\" operator=\"in\" />\n"
+ "<feGaussianBlur result=\"blur\" stdDeviation=\"%s\" in=\"composite\" />\n"
+ "<feOffset result=\"offsetBlur\" dx=\"%s\" dy=\"%s\" />\n"
+ "<feComposite in2=\"offsetBlur\" in=\"SourceGraphic\" operator=\"over\" result=\"compositeBlur\" />\n"
+ "</filter>\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