X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fextension%2Finternal%2Ffilter%2Fdrop-shadow.h;h=0cd2a8eeb34c166a788c2d61e28d890ce9ffd16e;hb=9dc68827cbd515262ecb8d5ae8547d9e82c72e00;hp=b83d3d44b9c5f98651d03063aafae70aa0b3752e;hpb=834a3fe9b1f099cb791357a9a4249ceee6c6122b;p=inkscape.git diff --git a/src/extension/internal/filter/drop-shadow.h b/src/extension/internal/filter/drop-shadow.h index b83d3d44b..0cd2a8eeb 100644 --- a/src/extension/internal/filter/drop-shadow.h +++ b/src/extension/internal/filter/drop-shadow.h @@ -34,15 +34,15 @@ public: "\n" "" N_("Drop Shadow") "\n" "org.inkscape.effect.filter.drop-shadow\n" - "2.0\n" - "50\n" - "4.0\n" - "4.0\n" + "2.0\n" + "50\n" + "4.0\n" + "4.0\n" "\n" "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("Black, blurred drop shadow") "\n" @@ -57,21 +57,26 @@ DropShadow::get_filter_text (Inkscape::Extension::Extension * ext) { if (_filter != NULL) g_free((void *)_filter); - float blur = ext->get_param_float("blur"); - float opacity = ext->get_param_float("opacity") / 100; - float x = ext->get_param_float("xoffset"); - float y = ext->get_param_float("yoffset"); + std::ostringstream blur; + std::ostringstream opacity; + std::ostringstream x; + std::ostringstream y; + + blur << ext->get_param_float("blur"); + opacity << ext->get_param_float("opacity") / 100; + x << ext->get_param_float("xoffset"); + y << ext->get_param_float("yoffset"); _filter = g_strdup_printf( "\n" - "\n" - "\n" - "\n" + "\n" + "\n" + "\n" "\n" "\n" "\n" "\n" - "\n", blur, opacity, x, y); + "\n", blur.str().c_str(), opacity.str().c_str(), x.str().c_str(), y.str().c_str()); return _filter; }; @@ -89,15 +94,15 @@ public: "\n" "" N_("Drop Glow") "\n" "org.inkscape.effect.filter.drop-glow\n" - "2.0\n" - "50\n" - "4.0\n" - "4.0\n" + "2.0\n" + "50\n" + "4.0\n" + "4.0\n" "\n" "all\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "" N_("White, blurred drop glow") "\n" @@ -112,25 +117,95 @@ DropGlow::get_filter_text (Inkscape::Extension::Extension * ext) { if (_filter != NULL) g_free((void *)_filter); - float blur = ext->get_param_float("blur"); - float opacity = ext->get_param_float("opacity") / 100; - float x = ext->get_param_float("xoffset"); - float y = ext->get_param_float("yoffset"); + std::ostringstream blur; + std::ostringstream opacity; + std::ostringstream x; + std::ostringstream y; + + blur << ext->get_param_float("blur"); + opacity << ext->get_param_float("opacity") / 100; + x << ext->get_param_float("xoffset"); + y << ext->get_param_float("yoffset"); _filter = g_strdup_printf( "\n" - "\n" - "\n" - "\n" + "\n" + "\n" + "\n" "\n" "\n" "\n" "\n" - "\n", blur, opacity, x, y); + "\n", blur.str().c_str(), opacity.str().c_str(), x.str().c_str(), y.str().c_str()); 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" + "127\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 */